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

Error loading csv file with string of length 8 #1036

Closed
gbarz opened this issue Oct 13, 2022 · 2 comments
Closed

Error loading csv file with string of length 8 #1036

gbarz opened this issue Oct 13, 2022 · 2 comments

Comments

@gbarz
Copy link

gbarz commented Oct 13, 2022

When trying to load a simple CSV file with the function: "CSV.read(testfile, DataFrame")

where testfile is a the following trivial csv:

A,B
name, 1.0
longname, 1.0

I receive the following error:

ERROR: MethodError: Cannot convert an object of type
Parsers.Result{String15} to an object of type
Parsers.Result{Any}

However, when 'longname' is shortened by 1 character, the CSV.read function works fine.

I am running Julia 1.8.2 and CSV v0.10.4 on an M1 Mac with MacOS 12.6

@nickrobinson251
Copy link
Collaborator

this is due to an issue in InlineStrings.jl v1.2.1 -- InlineStrings.jl is a dependency of CSV.jl and is used for small string types. The issue is fixed in InlineStrings.jl v1.2.2, which should already be available. Please try updating the dependencies with using Pkg; Pkg.update()

Pkg.status("InlineStrings"; mode=PKGMODE_MANIFEST) can show you which version you have.

If that Pkg.update() doesn't get you v1.2.2, could you try starting Julia with the environment variable
JULIA_PKG_SERVER_REGISTRY_PREFERENCE=eager then hopefully that'll get you v1.2.2 🤞
e.g.

$> JULIA_PKG_SERVER_REGISTRY_PREFERENCE=eager julia --project -q
julia> using Pkg; Pkg.update()

Alternatively, a workaround is to pass stringtype=String, like CSV.read(testfile, DataFrame; stringtype=String)

@gbarz
Copy link
Author

gbarz commented Oct 13, 2022

Thank you for the prompt response. As you noted, updating to InlineStrings.jl 1.2.2 fixed the issue.

@gbarz gbarz closed this as completed Oct 13, 2022
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