同じフォルダ内にある複数のcsvファイルをTOTAL.csvとして一つのファイルにまとめたいのですが以下のコードでエラーが出てしまいます。
コード import json,csv import pandas as pd import glob csv_files = glob.glob('*.csv') list = [] for i in csv_files: list.append(pd.read_csv(i)) df = pd.concat(list) df.to_csv("TOTAL.csv") --------------------------------------------------------------------------- EmptyDataError Traceback (most recent call last) <ipython-input-13-1535ff58b21a> in <module>() 8 9 for i in csv_files: ---> 10 list.append(pd.read_csv(i)) 11 df = pd.concat(list) 12 ~\Miniconda3\envs\cs2017_data\lib\site-packages\pandas\io\parsers.py 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, 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, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision) 653 skip_blank_lines=skip_blank_lines) 654 --> 655 return _read(filepath_or_buffer, kwds) 656 657 parser_f.__name__ = name ~\Miniconda3\envs\cs2017_data\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds) 403 404 # Create the parser. --> 405 parser = TextFileReader(filepath_or_buffer, **kwds) 406 407 if chunksize or iterator: ~\Miniconda3\envs\cs2017_data\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds) 762 self.options['has_index_names'] = kwds['has_index_names'] 763 --> 764 self._make_engine(self.engine) 765 766 def close(self): ~\Miniconda3\envs\cs2017_data\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine) 983 def _make_engine(self, engine='c'): 984 if engine == 'c': --> 985 self._engine = CParserWrapper(self.f, **self.options) 986 else: 987 if engine == 'python': ~\Miniconda3\envs\cs2017_data\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds) 1603 kwds['allow_leading_cols'] = self.index_col is not False 1604 -> 1605 self._reader = parsers.TextReader(src, **kwds) 1606 1607 # XXX pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.__cinit__ (pandas\_libs\parsers.c:6260)() EmptyDataError: No columns to parse from file 解決方法を教えていただけると幸いです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/20 04:51
2018/11/20 05:07
2018/11/20 05:12
2018/11/22 02:17