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 - parsing error solved by adding stringtype=String #1035

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

CSV.read - parsing error solved by adding stringtype=String #1035

Soldalma opened this issue Oct 13, 2022 · 2 comments

Comments

@Soldalma
Copy link

In the file C:\Users\fsald\.julia\packages\CSV\jFiCn\src\utils.jl the following function is generating an error when I try to read a CSV file:

@noinline function _parseany(T, buf, pos, len, opts)::Parsers.Result{Any}
    return Parsers.xparse(T, buf, pos, len, opts, Any)
end

The call to read the file is as follows:

CSV.read(full_path_astro, DataFrames.DataFrame)

Other CSV files were read without any problems. The file has about 45k rows and 600 columns. Until yesterday there were no errors, this file was read daily. When I deleted most columns, leaving only about 20, the file was read with no problems.

The error message is:

ERROR: TaskFailedException

    nested task error: MethodError: Cannot `convert` an object of type 
      Parsers.Result{String15} to an object of type
      Parsers.Result{Any}
    Closest candidates are:
      convert(::Type{T}, ::T) where T at Base.jl:61
Stacktrace:
     [1] _parseany(T::Type, buf::Vector{UInt8}, pos::Int64, len::Int64, opts::Parsers.Options)  
       @ CSV C:\Users\fsald\.julia\packages\CSV\jFiCn\src\utils.jl:455

Considering this error message we tried to remove the return type specification from the function parseany:

@noinline function _parseany(T, buf, pos, len, opts)
    return Parsers.xparse(T, buf, pos, len, opts, Any)
end

This worked. The file was read with no problems.

The problem still occurs if all but the two first lines of the file are deleted.

Astro_alpha_0.3_ConjunctionOrb_15.CSV

On the other hand, deleting all but the first 20 columns the file is read with no problems.

We solved the problem by changing the call to CSV.read to:

CSV.read(full_path_astro, DataFrame, stringtype=String)
@nickrobinson251
Copy link
Collaborator

hopefully this issue should be fixed if using InlineStrings.jl v1.2.2 (which is a dependency of CSV.jl)

Please can you try running using Pkg; Pkg.update() to see if that gets you InlineStrings.jl v1.2.2?
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()

@nickrobinson251
Copy link
Collaborator

will close this now, but please comment if you still have any issues - thanks for the report!

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