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

CSV.read not working #458

Closed
peytongreve opened this issue Jun 18, 2019 · 4 comments
Closed

CSV.read not working #458

peytongreve opened this issue Jun 18, 2019 · 4 comments

Comments

@peytongreve
Copy link

MY CODE:

using CSV
df2 = CSV.read("stats.csv")

Hi I am trying to read a csv and it won't open in julia because I keep getting this error:

ArgumentError: Symbol name may not contain \0

Stacktrace:
[1] Type at ./boot.jl:425 [inlined]
[2] #9 at ./none:0 [inlined]
[3] iterate at ./generator.jl:47 [inlined]
[4] collect(::Base.Generator{Base.Iterators.Enumerate{Array{String,1}},getfield(CSV, Symbol("##9#11")){Bool}}) at ./array.jl:619
[5] datalayout(::Int64, ::Array{UInt8,1}, ::Int64, ::Int64, ::Parsers.Options{false,true,false,Missing,UInt8,Nothing}, ::Int64, ::Bool, ::Nothing) at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/filedetection.jl:106
[6] file(::String, ::Int64, ::Bool, ::Int64, ::Nothing, ::Int64, ::Int64, ::Bool, ::Nothing, ::Bool, ::Array{String,1}, ::String, ::Nothing, ::Bool, ::Char, ::Nothing, ::Nothing, ::Char, ::Nothing, ::UInt8, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Dict{Int8,Int8}, ::Bool, ::Float64, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing) at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:249
[7] Type at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:158 [inlined]
[8] #read#57 at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:625 [inlined]
[9] read(::String) at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:625
[10] top-level scope at In[62]:2

@quinnj
Copy link
Member

quinnj commented Jun 18, 2019

Looks like there's a NUL byte in your column headers; you can do CSV.read("stats.csv"; normalizenames=true) to "scrub" the column names so they're valid.

@peytongreve
Copy link
Author

Now I'm getting this error:

Invalid UTF-8 string

Stacktrace:
[1] error(::String) at ./error.jl:33
[2] utf8proc_error(::Int64) at ./strings/unicode.jl:136
[3] utf8proc_map(::String, ::Int64) at ./strings/unicode.jl:141
[4] #normalize#1 at ./strings/unicode.jl:191 [inlined]
[5] normalize at ./strings/unicode.jl:170 [inlined]
[6] #normalize#1 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Unicode/src/Unicode.jl:56 [inlined]
[7] normalize at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Unicode/src/Unicode.jl:56 [inlined]
[8] normalizename(::String) at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/utils.jl:176
[9] #9 at ./none:0 [inlined]
[10] iterate at ./generator.jl:47 [inlined]
[11] collect(::Base.Generator{Base.Iterators.Enumerate{Array{String,1}},getfield(CSV, Symbol("##9#11")){Bool}}) at ./array.jl:619
[12] datalayout(::Int64, ::Array{UInt8,1}, ::Int64, ::Int64, ::Parsers.Options{false,true,false,Missing,UInt8,Nothing}, ::Int64, ::Bool, ::Nothing) at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/filedetection.jl:106
[13] file(::String, ::Int64, ::Bool, ::Int64, ::Nothing, ::Int64, ::Int64, ::Bool, ::Nothing, ::Bool, ::Array{String,1}, ::String, ::Nothing, ::Bool, ::Char, ::Nothing, ::Nothing, ::Char, ::Nothing, ::UInt8, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Dict{Int8,Int8}, ::Bool, ::Float64, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing) at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:249
[14] #File#20 at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:158 [inlined]
[15] Type at ./none:0 [inlined]
[16] #read#57 at /Users/peytongreve/.julia/packages/CSV/IwqOm/src/CSV.jl:625 [inlined]
[17] (::getfield(CSV, Symbol("#kw##read")))(::NamedTuple{(:normalizenames,),Tuple{Bool}}, ::typeof(CSV.read), ::String) at ./none:0
[18] top-level scope at In[100]:2

@quinnj
Copy link
Member

quinnj commented Jun 20, 2019

Hmmm, that error seems to suggest that your data actually isn't UTF8-encoded; do you know or have a way to check? If you can share the exact file (even if just privately w/ me), I can help take a look and try to figure out what's going on here. Note that the StringEncodings.jl package can help convert a file between encodings.

@peytongreve
Copy link
Author

I just converted the excel sheet I was using to a google sheet, then saved that as a csv

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

2 participants