I am following the csv type provider directions and everything works fine until I reference the field names, e.g. firstRow.Date. It returns the error "msft.fsx(362,25): error FS0039: The type 'Row' does not define the field, constructor or member 'Date'." Except for some path differences, my code is exactly what is on the site.
Would someone please help me understand the problem?
#r "nuget: FSharp.Data, 4.2.7"
open FSharp.Data
[<Literal>]
let ResolutionFolder = __SOURCE_DIRECTORY__
type Stocks = CsvProvider<"/msft.csv", ResolutionFolder = ResolutionFolder>
let msft = Stocks.Load(__SOURCE_DIRECTORY__ "/msft.csv").Cache()
let firstRow = msft.Rows |> Seq.head
let lastDate = firstRow.Date
CodePudding user response:
You're telling the type provider to search for a file in the root directory. Try changing it to using a relative path
type Stocks = CsvProvider<"./msft.csv", ResolutionFolder = ResolutionFolder>
// or
type Stocks = CsvProvider<"msft.csv", ResolutionFolder = ResolutionFolder>