Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load xlsx file using fread function?

Tags:

r

excel

I wanted to use fread function to load all the datasets as I think it would better to use one type of import function so I just sticked to the fread.

Few of my files are in xlsx format and I was saving them to csv format and then using the fread function was trying to load the datasets.

But I noticed that when I converted the xlsx files into csv, an empty or incomplete row was being created in the newly created csv files.

Is there a way I can resolve this issue? Can I load xlsx file somehow using the fread function rather than converting it to csv file and then loading it using the fread function?

like image 754
cyborg Avatar asked Jan 18 '18 02:01

cyborg


People also ask

Can fread read Xlsx?

The short answer is that you can't read xlsx files with fread , xlsx files have a very different format to the text files that fread is designed for.

Can fread read CSV?

We're able to successfully import the CSV file using the fread() function. Note: We used double backslashes (\\) in the file path to avoid a common import error. Notice that we didn't have to specify the delimiter either since the fread() function automatically detected that it was a comma.

What is one difference between Read_excel () and Read_xlsx ()?

Difference between read_xlsx() and read_excel() functions The result for reading the . xlsx file with the two functions is same. The only difference is that when read_excel() is used, excel_format() is called internally by the read_excel() function to determine if the path is xls or xlsx file from the file extension.


1 Answers

Here's how: Using command line tools directly in conjunction with csvkit like this

my.dt<-fread('in2csv my.xls')
like image 164
malcook Avatar answered Sep 23 '22 18:09

malcook