[Tutor] converting xls to csv
Emile van Sebille
emile at fenx.com
Sat Jun 6 21:33:27 CEST 2009
On 6/6/2009 12:19 PM Nick Burgess said...
> Thank you. The data is pretty much random throughout the csv's so I
> think I it would have to iterate over the entire rows . I need to
> search all .csv files in the current directory. I can get glob to
> return a list of files. How could I get csv.reader to open all the
> files in the list?
Open the files from within your loop.
> My loop logic must be bad.. I am using
> ActivePython 126.96.36.199. Any clues would be appreciated.
> pattern = re.compile(r'10\.191\.239\.0')
> files = glob.glob("*.csv")
> csv.reader(open (files), delimiter=' ', quotechar='|')
> for f in files:
do the open here
> for row in f:
> for cell in row:
> if pattern.search(cell):
> print ', '.join(row)
More information about the Tutor