I am using os.listdir
as part of a script to merge 14 files (each containing one column of data into 1 file)
For testing purposes I made the first row of each file a date starting at 010914
I was expecting it to come out something like:
010914,020914,030914,040914... etc.
Or in reverse:
180914,170914,160914,150914... etc.
These seem like the 2 logical read orders.
Currently each file is named result1
, result2
all the way up to result15
However the output actually reads something like:
010914.000000,120914.000000,150914.000000,160914.000000,170914.000000,180914.000000,020914.000000,030914.000000,040914.000000,050914.000000,080914.000000,090914.000000,100914.000000,110914.000000
what is causing python to read the files in this order.
Or is it perhaps the way in which I'm writing the files?
for f in files:
if fnmatch.fnmatch(f, '*.csv') and not fnmatch.fnmatch(f, 'TODAY.CSV'):
rows.append(open(os.path.join('C:\dev\OTQtxt\RAW_OTQ\\', f)).readlines())
iter = izip_longest(*rows)
for row in iter:
f_obj.write(','.join([field.strip() for field in row if field is not None]) + '\n')