问题描述
我正在尝试使用 Apache 箭头读取 csv 输入格式。示例 here 提到输入应该是 InputStream,但是在我的情况下,我只有一个 std::vector 的无符号字符。是否可以使用 apache 箭头解析它?我检查了 I/O interface 以查看是否存在“内存中”数据结构,但没有运气。 为方便起见,我复制粘贴了示例代码以及我的输入数据:
#include "arrow/csv/api.h"
{
// ...
std::vector<unsigned char> data;
arrow::io::IOContext io_context = arrow::io::default_io_context();
// how can I fit the std::vector to the input stream?
std::shared_ptr<arrow::io::InputStream> input = ...;
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
auto maybe_reader =
arrow::csv::TableReader::Make(io_context,input,read_options,parse_options,convert_options);
if (!maybe_reader.ok()) {
// Handle TableReader instantiation error...
}
std::shared_ptr<arrow::csv::TableReader> reader = *maybe_reader;
// Read table from CSV file
auto maybe_table = reader->Read();
if (!maybe_table.ok()) {
// Handle CSV read error
// (for example a CSV Syntax error or Failed type conversion)
}
std::shared_ptr<arrow::Table> table = *maybe_table;
}
任何帮助将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)