fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
816 stars 288 forks source link

CsvProvider: Incorrect truncation of sample file (by InferRows) #1439

Open nikoyak opened 2 years ago

nikoyak commented 2 years ago
#r "nuget: FSharp.Data"
type TP = FSharp.Data.CsvProvider< @"C:\Temp\multiline.csv", InferRows = 2>

multiline.csv:

f1,f2
"multi-
line field",2

Error:

Error: input.fsx (1,11)-(1,76) typecheck error The type provider "ProviderImplementation.CsvProvider" reported an error: Cannot read sample CSV from 'C:\Temp\multiline.csv': Couldn't parse row 1 according to schema: Expected 2 columns, got 1

In the sample, one row of data occupies two lines of the file. InferRows pre-truncates file lines, not data rows: https://github.com/fsprojects/FSharp.Data/blob/d5287e4ed3e27eca81033a3c7b3a0a9be52865e5/src/CommonProviderImplementation/Helpers.fs#L249-L261