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

Do not convert quoted cells

Open olivierlabayle opened this issue 1 year ago • 0 comments

Hi,

I think CSV.jl automatically detects and converts quoted cells to the detected type. When writing, one can specify quotestrings=true in order to keep the quotes. Unfortunately I don't think I can find a way to have the same behaviour at read time. For instance, in the following scenario I'd like to keep the A column as String since it is quoted but can't find a way to do it. I was looking for something like quotedasstring argument but can't find anything like it.

using CSV
using DataFrames

CSV.read(
    IOBuffer("""
    A,B
    "1001","a"
    "0002","b"
    """),
    DataFrame,
    typemap=Dict(String => String)
)

Is there a way to still achieve this or would it be possible in the near future? I know I could use the types=Dict(:A => String) unfortunately I can't really know that in advance.

olivierlabayle avatar May 05 '23 16:05 olivierlabayle