csv file reading header=TRUE default

222 views
Skip to first unread message

ivo welch

unread,
Feb 27, 2016, 11:18:50 PM2/27/16
to julia-users

I am a complete julia novice, so I may simply not understand the following.  when I type
julia> d=readcsv("myfile.csv")
julia> typeof(d)
Array{Any,2}

I think this shows that it interprets the header as data, and sets the columns to be of type "any".  alas https://dataframesjl.readthedocs.org/en/latest/io.html#advanced-options-for-reading-csv-files states that `header::Bool – Use the information from the file’s header line to determine column names. Defaults to true.`  but it only works if I force it to true:
julia> d=readcsv("myfile.csv", header=true)
julia> typeof(d)
Tuple{Array{Float64,2},Array{AbstractString,2}}  
 
seems to interpret the header as variable names.

is header=true the default on readcsv, is the docs wrong, or am I doing something wrong?

/iaw

ele...@gmail.com

unread,
Feb 27, 2016, 11:31:16 PM2/27/16
to julia-users
The link below points to "readtables" but you are using "readcsv" as the command.

ivo welch

unread,
Feb 28, 2016, 12:58:15 AM2/28/16
to julia-users

I see.  thank you.  it was a little confusing.  it was right under the header

Advanced Options for Reading CSV Files



----
Ivo Welch (ivo....@gmail.com)
http://www.ivo-welch.info/
J. Fred Weston Distinguished Professor of Finance
Anderson School at UCLA, C519
Free Finance Textbook, http://book.ivo-welch.info/
Exec Editor, Critical Finance Review, http://www.critical-finance-review.org/
Editor and Publisher, FAMe, http://www.fame-jagazine.com/

ele...@gmail.com

unread,
Feb 28, 2016, 1:39:58 AM2/28/16
to julia-users, ivo....@gmail.com
Indeed, but its in the dataframes package documentation, its all about "readtables", and nowhere in dataframes documentation is "readcsv" mentioned.
Reply all
Reply to author
Forward
0 new messages