csv - 获取 pyarrow.lib.ArrowInvalid:CSV 解析错误:预期 9 列,得到 1
问题描述
所以我第一次尝试 apache arrow 并想将整个 txt 文件目录读入 pyarrow 数据结构。我正进入(状态
pyarrow.lib.ArrowInvalid: CSV parse error: Expected 9 columns, got 1
当我运行下面的代码时?不知道如何调试它。任何帮助表示赞赏。如果有一本涵盖 python 和 pyarrow 的书也很高兴阅读它。
import pyarrow.csv as csv
import pyarrow as pa
l_all_files = ['x08.txt', 'x21.txt', 'x108.txt']
read_options = csv.ReadOptions( column_names= ('Sol' , 'H20', 'H50', 'H100', 'Date', 'Cv', 'Dys', 'Ple' , 'Cl') , skip_rows=26)
df_arrow_all = pa.concat_tables(( csv.read_csv(current_filename,read_options=read_options, ) for current_filename in l_all_files))
当 skip_rows = 26 完成时,这就是该行的样子
$sss 3431 3232 3249 25523 35.66 57 56le 77.73
解决方案
delmt = '\t'
df = csv.read_csv(current_filename
,read_options=read_options
,parse_options=csv.ParseOptions(delimiter=delmt)
这对我有用!信用:@迈克67
推荐阅读
- python - 没有得到预期的结果(np.frombuffer)
- c - 正常结构变量 A衰变指针或堆栈帧
- batch-file - 如何从“运行”对话框运行 cypher shell?
- javascript - 为什么输出文件名不包含来自 Webpack 的内容哈希?
- clojure - Clojure地图的最高3个值
- apache-beam - 如何在从 Kafka 源读取的 Apache Beam 中模拟事件延迟
- android - 滑动事件的未解析参考 GestureDetector
- r - 在 data.table 中使用 lapply 从列表列中提取元素
- javascript - 带有纯 HTML / PHP 和 Kirby 的 Recaptcha 和 Firebase
- javascript - 如何使用 javascript 将可靠值填充到下拉列表中