Skip to content

[CSV Type provider] When path to csv file is wrong, type provider shows strange errors. #953

@Chicker

Description

@Chicker

Description

I'm using CSV type provider with Schema parameter.

If I accidentally will write the wrong path to my csv file, or the file itself is accidentally will be deleted, then instead of showing error that the file is not found, CSV type provider showing the strange error.
csv_learn_fsx_ _zimport

Repro steps

Script which was used.

#r @"./packages/FSharp.Data/lib/net40/FSharp.Data.dll"
open FSharp.Data

[<Literal>]
let incorrectPathToCSV = @"../export_commerce_backoffice_orders.csv"

[<Literal>]
let correctPathToCSV = @"export_commerce_backoffice_orders.csv"

type OrdersCSV = 
  CsvProvider<  incorrectPathToCSV
              , Separators = "$"
              , HasHeaders = false          
              , Schema = "OrderNumber (string),OrderCreated (string),OrderTotal (float),FioShort (string option),PhoneNumber (string option),Email (string option),Comment (string option),FioFull (string option),Region (string option),Town (string option),Address (string option),Postindex (string option),ProductId (int option),ProductTitle (string),ProductQuantity (float),ProductPrice (decimal), NotUsed (string option)"
              , PreferOptionals = true
              >
let csv = OrdersCSV.GetSample()

Expected behavior

Type provider must shows error like this "Input file <...> not found!".

Actual behavior

Type provider shows the strange error like this "The provided schema contains 17 columns, the inference found 1 columns - please check the number of columns and the separator".

In addition:
If the Schema parameter is not presented and path to CSV file also incorrect, then the type provider does not show any error. But the code like this

for r in csv.Rows do
  printfn "%A" r

prints some nonsense (my incorrect path to csv file).

"../export_commerce_backoffice_orders.csv"
val it : unit = ()

Known workarounds

Write right path)

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