You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a very simple file that is failing to load. The only way to make it work is to add another column.
val it : CsvProvider<...> =
FSharp.Data.Runtime.CsvFile1[System.Tuple1[System.String]]
{Headers = Some [|"Tag"|];
NumberOfColumns = 1;
Quote = '"';
Rows = Error: Attempted to access an element as a type incompatible with the array.;
Separators = ",";}
I tried to load the file using CsvProvider and did not get any error. Here is what I tried (in a script file):
#r "packages/FSharp.Data/lib/net40/FSharp.Data.dll"
open FSharp.Data
type C = CsvProvider<"C:/temp/dummy.csv">
for r in C.GetSample().Rows do
printfn "%s" r.Tag
Could you share your F# code? Perhaps I'm using it differently than you are...
One possible reason for the error that I've seen before is when you use relative path as an argument to the CSV type provider - this may sometimes confuse F# Interactive (the editor thinks it is fine, but F# Interactive thinks it is in another folder and fails to find the file when running the type provider).
One fix for this is to use __SOURCE_DIRECTORY__ like this:
let [<Literal>] Dummy = __SOURCE_DIRECTORY__ + "/dummy.csv"
type C = CsvProvider<Dummy>
This way, the path passed to the CSV provider is a full path and it is more robust.
I have a very simple file that is failing to load. The only way to make it work is to add another column.
val it : CsvProvider<...> =
FSharp.Data.Runtime.CsvFile
1[System.Tuple
1[System.String]]{Headers = Some [|"Tag"|];
NumberOfColumns = 1;
Quote = '"';
Rows = Error: Attempted to access an element as a type incompatible with the array.;
Separators = ",";}
dummy.zip
The text was updated successfully, but these errors were encountered: