XLSX.jl icon indicating copy to clipboard operation
XLSX.jl copied to clipboard

DataFrames

Open ymer opened this issue 2 years ago • 3 comments

The tutorial says I should read to a DataFrame like this: DataFrame(XLSX.readtable("myfile.xlsx", "mysheet"))

However, this gives an error:

using DataFrames, XLSX
df = DataFrames.DataFrame(integers=[1, 2, 3, 4], strings=["Hey", "You", "Out", "There"])
XLSX.writetable("df.xlsx", df)

DataFrame(XLSX.readtable("df.xlsx", "Sheet1"))

While this works:

(cols, colnames) = XLSX.readtable("df.xlsx", "Sheet1")
df = DataFrame(cols, Symbol.(colnames))

ymer avatar Sep 03 '23 07:09 ymer

With the latest versions (DataFrames v1.6.1 & XLSX v0.10.0) , your first example works as expected but the second one thows an error :

  (cols, colnames) = XLSX.readtable("df.xlsx", "Sheet1") # ERROR: MethodError: no method matching iterate(::XLSX.DataTable)

jvigneron avatar Sep 21 '23 10:09 jvigneron

This sounds like you're just on an old version of XLSX.jl - it used to return a data/column names tuple (so you had to do DataFrame(XLSX.readtable("myfile.xlsx", 1)...)) but since version 0.8 it returns a Tables.jl compatible object so you can construct the DataFrame directly, see:

https://felipenoris.github.io/XLSX.jl/dev/migration/#Migrating-Legacy-Code-to-v0.8

Please check ] st in the environment in which you are running your code. If you can reproduce your issue on the latest XLSX version (0.10) please report back here, otherwise the issue can be closed.

nilshg avatar Dec 11 '23 15:12 nilshg

This is probably good to close?

nilshg avatar May 22 '24 09:05 nilshg