尝试导入csv字段并分析缺失值,以下是我的代码
import pandas as pd
import numpy as np
import smtplib
import glob
import os
import sys
path = "/home/tmp"
all_files = glob.glob(os.path.join(path,"*.csv"))
for fname in all_files:
print(fname)
df_header = pd.read_csv(fname,header=None,skiprows=1,encoding='cp1252')
print(df_header)
Error msg:
df_header = pd.read_csv(fname,header=None,skiprows=1,encoding='cp1252')
File "/usr/lib64/python2.7/site-packages/pandas/io/parsers.py", line 678, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/lib64/python2.7/site-packages/pandas/io/parsers.py", line 440, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/lib64/python2.7/site-packages/pandas/io/parsers.py", line 787, in __init__
self._make_engine(self.engine)
File "/usr/lib64/python2.7/site-packages/pandas/io/parsers.py", line 1014, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/usr/lib64/python2.7/site-packages/pandas/io/parsers.py", line 1708, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas/_libs/parsers.pyx", line 542, in pandas._libs.parsers.TextReader.__cinit__
pandas.errors.EmptyDataError: No columns to parse from file
请提出解决方案。
样本数据
头-n5路径的输出: