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

Error on CSV.read attempt

Open steveo314 opened this issue 2 years ago • 4 comments

Came across an issue when attempting to read a csv file into a Dataframe.

The code:

CSV.read("chuckle/random.csv", DataFrame)

The error:

ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type String

Without setting the quoted= and using this as a csv file:

"Name","Address","CSZ"
"Rachel Smith","123 Main St","Oldtown, NY 12345"
"Herbert "Bert" Jones","564 Second St","Oldtown, NY 12345"
"Joe Brown","879 Fourth St","Oldtown, NY 12345"

steveo314 avatar Dec 06 '23 16:12 steveo314

Does setting quoted=false give you the behaviour you expect? With quote=true (the default), i don't believe this is a valid CSV file.

Sharing a reproducible example would be helpful. At the very least, this is an unhelpful error message -- and it'd be great to improve that -- but i can't replicate it from the info provided.

nickrobinson251 avatar Dec 06 '23 16:12 nickrobinson251

This Issue came in reference from this conversation on Discourse. I was mainly concerned about this being a suboptimal error message: the core issue is malformed CSV input on a particular line, but the error is due to the immediate internal issue (can’t convert missing to string).

mikeingold avatar Dec 06 '23 17:12 mikeingold

@mikeingold does the OP look better now, or should I tweak it more?

steveo314 avatar Dec 06 '23 20:12 steveo314

The problem in this discourse discussion seems to be related.

TimG1964 avatar Apr 22 '24 13:04 TimG1964