CSV parsing with specific float formatting

Newbie question:

I’m loading a csv file in IfSharp (Jupyter) having defined this type:

type Expenses = CsvProvider<"/notebooks/expenses.csv",HasHeaders=false, Schema="date(string),category(string),amount(float),currency(string),note(string),tags(string)">

The amount uses “.” as thousand separator, eg 1.352,34.
Amount up to 999.99 are parsed correctly, however I can get amounts from 1000 to be parsed correctly…
I load the file as this:

type Expenses = CsvProvider<"/notebooks/expenses.csv",HasHeaders=false, Schema="date(string),category(string),amount(float),currency(string),note(string),tags(string)">

EDIT: this was a wrong code excerpt pasted in my question. See answers below to see how csv file is loaded.

What’s the best solution here (apart from editing the csv file ;)?

Thanks

Sounds like you need to use the Culture static parameter with an appropriate culture value. e.g.

type Expenses = CsvProvider<"/notebooks/expenses.csv",HasHeaders=false, Schema="date(string),category(string),amount(float),currency(string),note(string),tags(string)", Culture="DE">

That will probably also let you parse the Date field as an actual Date instead of a string.

1 Like

That’s exactly what I was missing. I can now load my csv with

let e = Expenses.Load("/notebooks/expenses.csv")

Thanks!