CsvProvider 跳过带有数据的第一行

CsvProvider skips first row with data

有一个 CSV 文件没有 headers。仅包含数据的行。为了设置 headers 我使用 sample.

type DisaggreggatedFinancialData = CsvProvider<"Schema.csv", HasHeaders=true, AssumeMissingValues=true, MissingValues=".">  

加载文件时,CsvProvider 未读取第一行数据。数据仅从第二行可用。当指定参数 HasHeaders = false 时,样本 headers 不可用。如何设置headers并从第一行读取数据?

保留 HasHeaders=false 并使用 Schema 参数指定列的名称:

let csv = CsvProvider<"1,2,3", HasHeaders = false, Schema = "Duration (float<second>),foo,float option">.GetSample()

来自CsvProvider Help

If the first row of the file is not a header row, you can specify the HasHeaders static parameter to false in order to consider that row as a data row. In that case, the columns will be named Column1, Column2, etc..., unless the names are overridden using the Schema parameter. Note that you can override only the name in the Schema parameter and still have the provider infer the type for you.