Danfo JS problem reading Excel file, works with CSV

624 Views Asked by At

I am trying to read a folder with csv and excel files with nodeJS and danfoJS.

Using danfoJS I have no problem reading the csv files but for the .xlsx files I am getting this error:

Error: ParamError: File not supported. file must be a url or an input File object

With this code:

const fileLocation = '/Users/riekus/Documents/notebook (analytics)/E/TIV data /test.xlsx'
let df2 = await dfd.readExcel(fileLocation)
print(df2); 

With a csv file on the same location this works:

const fileLocation = '/Users/riekus/Documents/notebook (analytics)/e/TIV data /test.csv'
let df2 = await dfd.readCSV(fileLocation)
print(df2); 

Reading the docs it is not clear to me what is going wrong here. I also tried to specify the sheet (which shouldn't be necessary) like this:

let df2 = await dfd.readExcel(fileLocation, {sheet: 'Sheet1')
1

There are 1 best solutions below

1
On

Try converting the file to .xsl.

The .xslx file format has limited compatibility.