如何讓 csvkit 轉換非常寬的 xlsx 檔案——奇怪的錯誤訊息

如何讓 csvkit 轉換非常寬的 xlsx 檔案——奇怪的錯誤訊息

我一直在嘗試將許多非常寬(超過 200 列)的 xlsx 文件轉換為 csv 文件,以便我可以將它們聚合到一個文件中進行分析。我一直在嘗試使用 csvkit,但它只是掛在文件上。

每次運行詳細模式時,錯誤訊息都會有所不同,如下所示:

C:\_analysis>in2csv -v 85910332_PE20160101_RECLMEXP.xlsx > test.csv
c:\python35\lib\site-packages\openpyxl\workbook\names\named_range.py:121: UserWarning: Discarded range with reserved name
  warnings.warn("Discarded range with reserved name")
Traceback (most recent call last):
  File "C:\Python35\Scripts\in2csv-script.py", line 9, in <module>
    load_entry_point('csvkit==0.9.1', 'console_scripts', 'in2csv')()
  File "c:\python35\lib\site-packages\csvkit\utilities\in2csv.py", line 82, in launch_new_instance
    utility.main()
  File "c:\python35\lib\site-packages\csvkit\utilities\in2csv.py", line 76, in main
    data = convert.convert(self.input_file, filetype, **kwargs)
  File "c:\python35\lib\site-packages\csvkit\convert\__init__.py", line 39, in convert
    return xlsx2csv(f, **kwargs)
  File "c:\python35\lib\site-packages\csvkit\convert\xlsx.py", line 66, in xlsx2csv
    value = c.value
  File "c:\python35\lib\site-packages\openpyxl\cell\read_only.py", line 107, in value
    if self.data_type == 'b':
KeyboardInterrupt

當我再次運行時,錯誤略有不同:

C:\_analysis>in2csv -v 85910332_PE20160101_RECLMEXP.xlsx > test.csv
c:\python35\lib\site-packages\openpyxl\workbook\names\named_range.py:121: UserWarning: Discarded range with reserved name
  warnings.warn("Discarded range with reserved name")
Traceback (most recent call last):
  File "C:\Python35\Scripts\in2csv-script.py", line 9, in <module>
    load_entry_point('csvkit==0.9.1', 'console_scripts', 'in2csv')()
  File "c:\python35\lib\site-packages\csvkit\utilities\in2csv.py", line 82, in launch_new_instance
    utility.main()
  File "c:\python35\lib\site-packages\csvkit\utilities\in2csv.py", line 76, in main
    data = convert.convert(self.input_file, filetype, **kwargs)
  File "c:\python35\lib\site-packages\csvkit\convert\__init__.py", line 39, in convert
    return xlsx2csv(f, **kwargs)
  File "c:\python35\lib\site-packages\csvkit\convert\xlsx.py", line 58, in xlsx2csv
    for i, row in enumerate(sheet.iter_rows()):
  File "c:\python35\lib\site-packages\openpyxl\worksheet\iter_worksheet.py", line 103, in get_squared_range
    for _event, element in p:
  File "c:\python35\lib\xml\etree\ElementTree.py", line 1290, in __next__
    for event in self._parser.read_events():
  File "c:\python35\lib\xml\etree\ElementTree.py", line 1257, in read_events
    index = self._index
KeyboardInterrupt

有任何想法嗎?

我運行的是 Windows 10,來源檔案位於 Excel 2013、Python 3.5.1 和以下函式庫版本 csvkit==0.9.1 jdcal==1.2 numpy==1.10.2 openpyxl==2.2.0b1 python-dateutil ==2.2 六==1.10.0 SQLAlchemy==1.0.13 xlrd==1.0.0

相關內容