Why exactly do you want a CSV.File
? If you want to end up with a DataFrame
you can use DataFrame
as sink
in CSV.read
.
You could just manually convert after reading, using something like
julia> df = CSV.read("test.csv", DataFrame) # initial DataFrame
2×3 DataFrame
Row │ Col1 Col2 Col3
│ Int64 Float64 String3
─────┼─────────────────────────
1 │ 1 2.3 sdf
2 │ 12 -0.213 ds
julia> for (col_symb, col_type) in zip((:Col1, :Col3), (Float32, String))
df[!, col_symb] .= convert.(col_type, df[!, col_symb])
end
julia> df
2×3 DataFrame
Row │ Col1 Col2 Col3
│ Float32 Float64 String
─────┼──────────────────────────
1 │ 1.0 2.3 sdf
2 │ 12.0 -0.213 ds
as in this topic