获取 pyarrow.lib.ArrowInvalid:CSV 解析错误:预期 9 列,得到 1

问题描述 投票:0回答: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
csv pyarrow
1个回答
0
投票
delmt = '\t' 
df = csv.read_csv(current_filename
                 ,read_options=read_options
                 ,parse_options=csv.ParseOptions(delimiter=delmt)

这对我有用! 信用:@Mike67

© www.soinside.com 2019 - 2024. All rights reserved.