如何使用Pandas(python)读取7z文件并将其转换为csv?

时间:2016-12-16 20:28:10

标签: python-2.7 csv pandas 7zip sklearn-pandas

我有7z文件想要使用Pandas将它们转换为csv来预处理数据。我有python 2.7。

我试过这个:

import pandas as pd
data = pd.read_csv('train_2011_2012_2013.7z.002', header = None)
print data

我遇到了这个错误

CParserError                              Traceback (most recent call last)
<ipython-input-9-74098fd0c476> in <module>()
      1 
----> 2 data = pd.read_csv('train_2011_2012_2013.7z.001', header = None)
      3 print data

/root/anaconda2/lib/python2.7/site-packages/pandas/io/parsers.pyc in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
    560                     skip_blank_lines=skip_blank_lines)
    561 
--> 562         return _read(filepath_or_buffer, kwds)


CParserError: Error tokenizing data. C error: Expected 1 fields in line 17, saw 2

这里有什么问题?

0 个答案:

没有答案