I have several csv files that are named: list_csv_X with X going from 0 to 5. I would like to do a loop to read them with Python.
I am currently doing it manually:
for filepath in list_csv_0:
with open(filepath,'r',encoding="utf8", errors='ignore') as csvfile:
BLABLABLA
for filepath in list_csv_1:
with open(filepath,'r',encoding="utf8", errors='ignore') as csvfile:
BLABLABLA
for filepath in list_csv_2:
with open(filepath,'r',encoding="utf8", errors='ignore') as csvfile:
BLABLABLA
How can I do it?
Thanks a lot!
If I understand correctly, each of your 6 items is a list of filenames, yes?
I am assuming that, because you are doing this, and saying that it currently works:
That would lead to an error, if
list_csv_0were a filename, becausefilepathvalues would be individual characters of the filename, not ever a whole filename.You can loop over the lists