Importing data with ambiguous dates

You can turn off type detection by using the types kw argument

One such way:

file = CSV.File(IOBuffer(data); types=[Int, String]) |> DataFrame
4×2 DataFrame
 Row │ code   date       
     │ Int64  String     
─────┼───────────────────
   1 │     0  2019-02
   2 │     1  2019-01
   3 │     3  2019
   4 │     4  2019-04-23

You can even do it just for a single column

file = CSV.File(IOBuffer(data); types=Dict("date"=>String)) |> DataFrame
or
file = CSV.File(IOBuffer(data); types=Dict(:date=>String)) |> DataFrame

and post process the DataFrame to do what you want using filter or subset or whatever

4 Likes