How to transfer data from file FSharp.Data.CsvProvider to Deedle.Frame?

I am trying to pass data from FSharp.Data.CsvProvider to Deedle.Frame.

I am almost new to F # and I need to convert some CSV files from the "it-IT" culture to "en-US", so I can use the data.

I found Deedle and I want to learn how to use it, but I could not directly convert the data from the CSV file to Deedle (at least this is what is printed in F # interactive).

I noticed that CsvProvider is doing the conversion, but after several days of trying, I can’t transfer the data.

+6
source share
1 answer

I believe that Deedle should deal with CSV files that use a non-American culture:

let frame = Frame.ReadCsv("C:\\test.csv", culture="it-IT") 

However, if you want to use a provider like CSV for any reason, you can use:

 let cs = new CsvProvider<"C:/data/fb.csv">() cs.Rows |> Frame.ofRecords |> Frame.indexColsWith cs.Headers.Value 

In this case, Frame.ofRecords used, which creates a data frame from any .NET collection and extends the properties of objects in the form of columns. The CSV provider presents the data as tuples, so this does not correctly define the headers, but the Frame.indexColsWith function allows you to name the explicitness of the headers.

+5
source

Source: https://habr.com/ru/post/970911/


All Articles