0

我有一个看起来像的文件

2|1|abc
3|4|def
from pyarrow import csv

a = csv.read_csv("file.csv", parse_options=csv.ParseOptions(delimiter="|", header_rows=0))

那么如何指定明确的列名呢?在文档中找不到。

Traceback (most recent call last):
  File "C:\data\dask\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-15-18e80408b284>", line 2, in <module>
    a = csv.read_csv("c:/data/Performance_All/Performance_2003Q3.txt", parse_options=csv.ParseOptions(delimiter="|", header_rows=0))
  File "pyarrow\_csv.pyx", line 450, in pyarrow._csv.read_csv
  File "pyarrow\error.pxi", line 85, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: header_rows == 0 needs explicit column names
4

2 回答 2

3

请参阅https://issues.apache.org/jira/browse/ARROW-6231。我们正在讨论自动分配列名——您的反馈会很有用。同时,您必须传递明确的列名。

于 2019-08-24T19:57:16.150 回答
2

column_names参数已添加到https://issues.apache.org/jira/browse/ARROW-5747中,该参数将包含在 0.15 版本中。

于 2019-08-26T15:59:14.590 回答