I am reading pipe delimited data from a text file. There are some parsing issues and I am handing the same while pd.read_csv(error_bad_lines=False)
files = [f for f in filepath for f in os.listdir(filepath)]
df_f=[]
for i in files:
df = df = pd.read_csv(i,usecols=col_lst,sep='|',engine='python',encoding='iso-8859-1',error_bad_lines=False)
df_f.append(df)
The above method is removing the bad lines due to |
parsing issues and going ahead.
Objective: Can I get a list of warning messages for the bad lines in the above example and create list of the same.
Eg.
df_f =[]
bad_line =[]
for i in files:
df = df = pd.read_csv(i,usecols=col_lst,sep='|',engine='python',encoding='iso-8859-1',error_bad_lines=False)
#Pseudo Code Below. Need assistance in building it correctly
if bad_lines:
bad_line.append(bad_lines)
df_f.append(df)
So in other words how can I append the warning messages into bad_line
list.
Any thought on this would be appreciated.