Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Columns argument in XLSX.readtable() not recognized #69

Closed
BenjaminBorn opened this issue Dec 1, 2018 · 3 comments
Closed

Columns argument in XLSX.readtable() not recognized #69

BenjaminBorn opened this issue Dec 1, 2018 · 3 comments

Comments

@BenjaminBorn
Copy link

I tried to use readable to directly read into a dataframe but it seems that I cannot pass the column argument as described in the documentation. If I do

df = DataFrame(XLSX.readtable("my_data.xlsx", "raw_data", columns="C"; first_row=20, header=true)...)

I get the error

MethodError: no method matching readtable(::String, ::String; columns="C", first_row=20, header=true)
Closest candidates are:
  readtable(::AbstractString, ::Union{Int64, AbstractString}; first_row, column_labels, header, infer_eltypes, stop_in_empty_row, stop_in_row_function, enable_cache) at /Users/born/.julia/packages/XLSX/j2fqF/src/read.jl:538 got unsupported keyword argument "columns"
kwerr(::NamedTuple{(:columns, :first_row, :header),Tuple{String,Int64,Bool}}, ::Function, ::String, ::String) at error.jl:97
(::getfield(XLSX, Symbol("#kw##readtable")))(::NamedTuple{(:columns, :first_row, :header),Tuple{String,Int64,Bool}}, ::typeof(XLSX.readtable), ::String, ::String) at none:0
top-level scope at none:0
include_string(::Module, ::String, ::String) at loading.jl:1008
include_string(::Module, ::String, ::String, ::Int64) at eval.jl:30
(::getfield(Atom, Symbol("##114#119")){String,Int64,String})() at eval.jl:94
withpath(::getfield(Atom, Symbol("##114#119")){String,Int64,String}, ::String) at utils.jl:30
withpath at eval.jl:46 [inlined]
#113 at eval.jl:93 [inlined]
with_logstate(::getfield(Atom, Symbol("##113#118")){String,Int64,String}, ::Base.CoreLogging.LogState) at logging.jl:395
with_logger at logging.jl:491 [inlined]
#112 at eval.jl:92 [inlined]
hideprompt(::getfield(Atom, Symbol("##112#117")){String,Int64,String}) at repl.jl:85
macro expansion at eval.jl:91 [inlined]
(::getfield(Atom, Symbol("##111#116")))(::Dict{String,Any}) at eval.jl:86
handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at comm.jl:164
(::getfield(Atom, Symbol("##19#21")){Array{Any,1}})() at task.jl:259

Looking at the source at

function readtable(filepath::AbstractString, sheet::Union{AbstractString, Int}; first_row::Int = 1, column_labels::Vector{Symbol}=Vector{Symbol}(), header::Bool=true, infer_eltypes::Bool=false, stop_in_empty_row::Bool=true, stop_in_row_function::Union{Nothing, Function}=nothing, enable_cache::Bool=false)

there also doesn't seem to exist a columns= argument. So is this just a mistake in the documentation or would it be possible to specify the columns to be extracted in readtable?

I'm using Julia 1.0.2 on MacOS. Thanks for your help.

felipenoris added a commit that referenced this issue Dec 2, 2018
@felipenoris
Copy link
Owner

felipenoris commented Dec 2, 2018

Thanks for reporting this bug!
I think this API got lost in some update. Now you can use it as described in the docs. But be aware that columns is not a keyword parameter. So your code would work like this:

df = DataFrame(XLSX.readtable("my_data.xlsx", "raw_data", "C"; first_row=20, header=true)...)

@AndyYangjd
Copy link

Hi, felipenoris,
I'm a little puzzle about how to select multi-column which are not coninuous.
For example, i've tried "C G", ":C :G", "CG", but all wrong.
Can you add an example about this in document?

I'm using julia 1.4.2 and XLSX 0.7.2.
Thank u.

@felipenoris
Copy link
Owner

@AndyYangjd non-continuous column ranges are not supported. I'll update the docs on that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants