Hey there!
I have to following problem. I want to read in data ( .csv ) which has the following structure:
data = """
col1;col2;col3;col4;col5
"05.02.2023";1000,01;2000,02;3000,03;12:00:00
"06.02.2023";4000,04;5000,05;6000,06;12:00:00
"""
This data can be easily read, by stating that ‘,’ is used as a decimal instead of ‘.’
file = CSV.File(IOBuffer(data); delim=';', decimal=',', dateformat="dd.mm.yyyy")
2-element CSV.File:
CSV.Row: (col1 = Dates.Date("2023-02-05"), col2 = 1000.01, col3 = 2000.02, col4 = 3000.03, col5 = String15("12:00:00"))
CSV.Row: (col1 = Dates.Date("2023-02-06"), col2 = 4000.04, col3 = 5000.05, col4 = 6000.06, col5 = String15("12:00:00"))
However my data looks like this:
data = """
col1;col2;col3;col4;col5
"05.02.2023";1.000,01;2.000,02;3.000,03;12:00:00
"06.02.2023";4.000,04;5.000,05;6.000,06;12:00:00
"""
There is an extra ‘.’ which separates digits of 1000, like it’s implemented in Julia with ‘_’ underscore. So 1000,0 = 1.000,0 = 1_000,0
Is there a way of handling such problems easily, without needing to do something like this":
-read file line by line
-do this where needed: replace(x, “.” => “”)
-save file
-then read in with CSV
Thanks for your help!