Using Python 2.7 and Pandas
I need to parse my directory and build a bunch of CSV. If the CSV is empty, the script terminates and gives an error message:
pandas.io.common.EmptyDataError: No columns to parse from file
If I have file paths stored in
file_paths=[]
How did I read each of them and only built non-empty CSVs? If I have an empty data framework defined as df = [], I am trying to execute the following code
for i in range(0,len(file_paths)):
if pd.read_csv(file_paths[i] == ""):
print "empty"
else df.append(pd.read_csv(file_paths[i],header=None))
source
share