Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nikoyak opened this issue May 26, 2022 · 0 comments
Open

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

nikoyak opened this issue May 26, 2022 · 0 comments

Comments

@nikoyak
Copy link
Contributor

nikoyak commented May 26, 2022

#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:

match maxNumberOfRows with
| None -> reader.ReadToEnd()
| Some max ->
let sb = StringBuilder()
let max = ref max
while !max > 0 do
let line = reader.ReadLine()
if line = null then
max := 0
else
line |> sb.AppendLine |> ignore
decr max
sb.ToString()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant