David Crook
David Crook

Reputation: 2730

F# CSV Provider type mismatch

I'm having an issue with the F# CSV Type provider and getting a type mismatch. I'm new to F#, so it very well could be a basic issue. I have put the file up on blob storage so you can replicate easier. https://analyzethis.blob.core.windows.net/voterinfo/WakeCountyVoterCSV note: you will need to change the providers file location to your download location to replicate exactly. You may be able to load dynamically from blob as well.

The error I get is:

Type mismatch: Expecting a seq< CsvProvider<...>.Row> -> int

but given a

seq< CsvProvider<...>.Row> -> unit

Type int does not match unit

code:

open FSharp.Data
type voterType = CsvProvider<"C:\\Users\\dacrook\\Documents\\vrdb\\VoterCSVData2.csv", AssumeMissingValues=true, MissingValues="">

[<EntryPoint>]
let main argv = 
    let voterData = voterType.Parse("C:\\Users\\dacrook\\Documents\\vrdb\\VoterCSVData2.csv")
    voterData.Rows |> Seq.iter(fun r -> printfn "%A" r)

Any assistance is greatly appreciated!

Thanks,

~David

Upvotes: 0

Views: 298

Answers (1)

Steve
Steve

Reputation: 2345

main has an expected return type of int so your last line of code in the main function needs to be an int expression

open FSharp.Data
type voterType = CsvProvider<"C:\\Users\\dacrook\\Documents\\vrdb\\VoterCSVData2.csv",   AssumeMissingValues=true, MissingValues="">

[<EntryPoint>]
let main argv = 
    let voterData = voterType.Parse("C:\\Users\\dacrook\\Documents\\vrdb\\VoterCSVData2.csv")
    voterData.Rows |> Seq.iter(fun r -> printfn "%A" r)
    0  // <--- Add an int as the return value

Upvotes: 2

Related Questions