22

I have a pandas dataframe dfwin. enter image description here

And I save it to feather format hoping I can read it in R.

enter image description here

But R always throws the error "Error in openFeather(path): Invalid: Not a feather file Traceback:

  1. read_feather("./aFolder/dfwin.feather")
  2. feather(path)
  3. openFeather(path)"

Can someone help me here? The R code I used is below:

library(feather)
dfwin = read_feather('./aFolder/dfwin.feather')```
L.Yang
  • 553
  • 1
  • 6
  • 12
  • 7
    Development on feather in R [moved](https://arrow.apache.org/blog/2019/08/08/r-package-on-cran/) to [arrow](https://arrow.apache.org/docs/r/), so it's probably a versioning thing. But you might consider using parquet, which is part of arrow as well and which is well-supported by a broader range of languages. – alistaire May 26 '20 at 03:51

2 Answers2

27

I had exactly the same problem and I found a solution for it by using arrow package in r. the following code can be used instead of read_feather() from feather library.

arrow::read_feather("./aFolder/dfwin.feather")

I still don't understand why the function from the feather package doesn't work but the same function from arrow package can fix the issue.

Reza Rezaei
  • 487
  • 4
  • 12
  • I encountered this same problem when I upgraded the python version I was using to write the feather from 3.7 to 3.8. That might be a clue as to the cause, but it still doesn't seem to explain it. I thought the feather package called arrow underneath anyway. This solutions still works though, thanks! – Aidan Morrison Jul 09 '20 at 01:58
  • 2
    This didn't work for me, and but dumping my pandas datafame to parquet (`df.to_parquet(...)`) and then reading it in R with `arrow::read_parquet(...)` worked for me – Jthorpe Oct 27 '21 at 22:12
0

Try this

import pyarrow.feather as feather
feather.write_feather(dataframe, filename)

Then use Reza's line of code in R o read the saved feather filename.

Victor AQ
  • 51
  • 1
  • 2