Skip to content

[CSV Type provider] The strange error when defining very long Schema parameter #952

@Chicker

Description

@Chicker

Description

I have csv file with 16 columns. Because header (first row) is missing I am using Schema static paramater for naming columns. Since the number of columns is large enough, to improve readability of the code I am using line breaks when setting the parameter Schema. As result the CSV type provider shows the error "The input sequence contains more than one element"

Repro steps

Script which was used.

#r @"C:\Users\vadim\Documents\Develop\FSharp\zImport\packages\FSharp.Data\lib\net40\FSharp.Data.dll"

open FSharp.Data

type OrdersCSV = 
  CsvProvider<  @"export_commerce_backoffice_orders.csv"
              , Separators = "$"
              , HasHeaders = false          
              , Schema = "OrderNumber (string),
                          OrderCreated (string),
                          OrderTotal (string),
                          FioShort (string),
                          PhoneNumber (string),
                          Email (string),
                          Comment (string),
                          FioFull (string),
                          Region (string),
                          Town (string),
                          Address (string),
                          Postindex (string),
                          ProductId (string),
                          ProductTitle (string),
                          ProductQuantity (string),
                          ProductPrice (string)"
              >


 let csv = OrdersCSV.GetSample()

Expected behavior

No errors :)

Actual behavior

CSV type provider shows the error "The input sequence contains more than one element".

Known workarounds

If I rewrite Schema string in a very long line, the error will be gone.

My suggestion: remove all the special characters in the user defined string "Schema".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions