c++ - 在 C++ 中使用 Apache Arrow 打开 CSV 文件
问题描述
我正在尝试使用 Apache Arrow 读取 csv 文件,但我无法理解 InputStream ......看来他们文档中的示例已经过时了。
我对示例进行了一些调整,但出现“访问冲突读取位置”异常。知道我在做什么错吗?
谢谢
我的代码:
arrow::MemoryPool* pool = arrow::default_memory_pool();
std::shared_ptr<arrow::io::ReadableFile> infile;
infile->Open("test.csv", pool);
auto read_options = arrow::csv::ReadOptions::Defaults();
auto parse_options = arrow::csv::ParseOptions::Defaults();
auto convert_options = arrow::csv::ConvertOptions::Defaults();
// Instantiate TableReader from input stream and options
std::shared_ptr<arrow::csv::StreamingReader> reader;
auto res1 = reader->Make(pool, infile, read_options, parse_options, convert_options);
if (!res1.ok()) {
// Handle TableReader instantiation error...
}
std::shared_ptr<arrow::Table> table;
// Read table from CSV file
auto res2 = reader->ReadAll(&table);
if (!res2.ok()) {
// Handle CSV read error
// (for example a CSV syntax error or failed type conversion)
}
解决方案
推荐阅读
- xamarin - 如何在不使用 clear 方法的情况下清除 observable 集合
- angular - 如何使 mat-select 始终在 angular2 的表单字段下打开?
- url - Yii2-curl oAuth2 与 zoho
- android - 应用程序在 android studio 模拟器上运行但不在真实设备上:(
- python - 通过执行依赖于多个索引的操作来创建列表 - python
- highcharts - 根据不规则数据绘制 Highcharts 热图
- meteor - 如何从命令行调用 Meteor 方法
- spring - Spring OAuth2 在成功验证时重定向到原始 URL
- jquery - 使用 jquery 每 5 秒倒计时
- python - 单从多拆分