ArgumentError: no default `Tables.columns` implementation for type: XLSX.XLSXFile

275 views Asked by At

I have a very simple excel file (.xlsx) it contains just 2 columns and 2 rows with values. But when I run the code below I get ArgumentError: no default `Tables.columns` implementation for type: XLSX.XLSXFile, for both readxlsx and openxlsx Why is that? Is it something with DataFrames or with XLXS pkg?

The excel file looks like this enter image description here

|  text  | text  |
------------------
|   0    |   1   |
------------------

using DataFrames
using XLSX

df = XLSX.readxlsx("Test1.xlsx")

As a suggested solution I'm running the following code The excel file looks like this

|  text  | text  |
------------------
|   0    |   1   |
------------------

using DataFrames
using XLSX

df = DataFrame(XLSX.readtable("Test1.xlsx", "Blad1"))

but that gives the following error ArgumentError: 'Tuple{Vector{Any}, Vector{Symbol}}' iterates 'Vector{Any}' values, which doesn't satisfy the Tables.jl `AbstractRow` interface

1

There are 1 answers

4
Ashlin Harris On

The tutorial includes a relevant example with readtable:

julia> using DataFrames, XLSX

julia> df = DataFrame(XLSX.readtable("myfile.xlsx", "mysheet"))
3×2 DataFrames.DataFrame
│ Row │ HeaderA │ HeaderB  │
├─────┼─────────┼──────────┤
│ 1   │ 1       │ "first"  │
│ 2   │ 2       │ "second" │
│ 3   │ 3       │ "third"  │

I've tried to replicate your setup as closely as possible with the information you've given. However, I can't replicate your error with readtable:

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.1 (2022-09-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.8) pkg> activate --temp
  Activating new project

julia> using DataFrames, XLSX

julia> df = DataFrame(XLSX.readtable("Test1.xlsx", "Blad1"))
1×2 DataFrame
 Row │ Zero  One
     │ Any   Any
─────┼───────────
   1 │ 0     1

This makes me suspect that the problem is elsewhere. Could you please try running everything in a temporary project, as I've done here? I want to be sure that another package is not interfering.