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

Failed to parse csv with cyrillic values #1034

Closed
sairus7 opened this issue Oct 13, 2022 · 7 comments
Closed

Failed to parse csv with cyrillic values #1034

sairus7 opened this issue Oct 13, 2022 · 7 comments

Comments

@sairus7
Copy link

sairus7 commented Oct 13, 2022

I have a strange bug that never appeared before on the same workflows with the same CSV.jl version.

str = """record	number
rec1	2166
rec2	2166
rec3	2155
GROSS	20760
Average	20760"""
io = IOBuffer(str)
df = CSV.File(io, delim = '\t') # this works fine

str = """record	number
rec1	2166
rec2	2166
rec3	2155
GROSS	20760
Среднее	20760"""
io = IOBuffer(str)
df = CSV.File(io, delim = '\t') #error

The last line gives me error:

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\gvg\.julia\packages\CSV\jFiCn\src\utils.jl:455
 [2] parsevalue!
   @ C:\Users\gvg\.julia\packages\CSV\jFiCn\src\file.jl:810 [inlined]
 [3] parserow
   @ C:\Users\gvg\.julia\packages\CSV\jFiCn\src\file.jl:620 [inlined]
 [4] parsefilechunk!(ctx::CSV.Context, pos::Int64, len::Int64, rowsguess::Int64, rowoffset::Int64, columns::Vector{CSV.Column}, #unused#::Type{Tuple{}})
   @ CSV C:\Users\gvg\.julia\packages\CSV\jFiCn\src\file.jl:551
 [5] CSV.File(ctx::CSV.Context, chunking::Bool)
   @ CSV C:\Users\gvg\.julia\packages\CSV\jFiCn\src\file.jl:291
 [6] File
   @ C:\Users\gvg\.julia\packages\CSV\jFiCn\src\file.jl:226 [inlined]
 [7] #File#25
   @ C:\Users\gvg\.julia\packages\CSV\jFiCn\src\file.jl:222 [inlined]
 [8] top-level scope
   @ REPL[21]:1
@sairus7
Copy link
Author

sairus7 commented Oct 13, 2022

The problem is with transition from InlineStrings@1.2.0 to InlineStrings@1.2.1

@nickrobinson251
Copy link
Collaborator

Sorry about that. Can you try with InlineStrings v1.2.2 ?

@nickrobinson251
Copy link
Collaborator

If you do using Pkg; Pkg.update() hopefully that will now get v1.2.2 and hopefully fix the issue

@sairus7
Copy link
Author

sairus7 commented Oct 13, 2022

Looks like its not yet registered:

(@v1.8) pkg> activate --temp
  Activating new project at `C:\Users\gvg\AppData\Local\Temp\jl_QCIhAM`

(jl_QCIhAM) pkg> add InlineStrings
    Updating registry at `C:\Users\gvg\.julia\registries\General.toml`
   Resolving package versions...
    Updating `C:\Users\gvg\AppData\Local\Temp\jl_QCIhAM\Project.toml`
  [842dd82b] + InlineStrings v1.2.1
    Updating `C:\Users\gvg\AppData\Local\Temp\jl_QCIhAM\Manifest.toml`
  [842dd82b] + InlineStrings v1.2.1
  [69de0a69] + Parsers v2.4.2
  [ade2ca70] + Dates
  [de0858da] + Printf
  [4ec0a83e] + Unicode

(jl_QCIhAM) pkg> add InlineStrings@1.2.2
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package InlineStrings [842dd82b]:
 InlineStrings [842dd82b] log:
 ├─possible versions are: 1.0.0-1.2.1 or uninstalled
 └─restricted to versions 1.2.2 by an explicit requirement — no versions left

@nickrobinson251
Copy link
Collaborator

hmm 🤔 i should have been registered a couple hours ago JuliaRegistries/General#70091

@nickrobinson251
Copy link
Collaborator

The issue does seem fixed on InlineStrings v1.2.2

If you start 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
(@v1.8) pkg> add InlineStrings@1.2.2
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `~/.julia/environments/v1.8/Project.toml`
  [842dd82b] + InlineStrings v1.2.2
    Updating `~/.julia/environments/v1.8/Manifest.toml`
  [842dd82b] + InlineStrings v1.2.2

(thanks @giordano for this suggestion via slack)

@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