apache arrow - reading csv file

China☆狼群 提交于 2019-12-14 03:28:14

问题


all I'm working with apache arrow now.

When reading csv file with arrow::csv::TableReader::Read function, I want to read this file as a file with no header.

But, it reads csv file and treat first row as csv header(data field). Is there any options to read csv file with no header?

Thanks


回答1:


Check out the ParserOptions

int32_t arrow::csv::ParseOptions::header_rows = 1

It can be defined as third argument in TableReader::Make(...).

static Status   Make(MemoryPool *pool, std::shared_ptr< io::InputStream > input, const ReadOptions &, const ParseOptions &, const ConvertOptions &, std::shared_ptr< TableReader > *out)

Check the documentation: https://arrow.apache.org/docs/cpp/namespacearrow_1_1csv.html

and these test files: https://github.com/apache/arrow/tree/3cf8f355e1268dd8761b99719ab09cc20d372185/cpp/src/arrow/csv




回答2:


You can't at the moment. You'll got an error if header_rows == 0:

if (parse_options_.header_rows == 0) {
    // TODO allow passing names and/or generate column numbers?
    return Status::Invalid("header_rows == 0 needs explicit column names");
}

(https://github.com/apache/arrow/blob/3cf8f355e1268dd8761b99719ab09cc20d372185/cpp/src/arrow/csv/reader.cc)



来源:https://stackoverflow.com/questions/54246801/apache-arrow-reading-csv-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!