Created
October 22, 2015 16:55
-
-
Save f-ewald/1193b137a57b23ac21d3 to your computer and use it in GitHub Desktop.
Combines files by filename into one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file combiner | |
# combines csv files into one | |
import os | |
for f in os.listdir('export'): | |
print 'Processing file %s' % f | |
with open('export/' + f, 'r') as h: | |
filename = str() | |
if f.endswith('electricityrates.csv'): | |
filename = 'electricityrates.csv' | |
elif f.endswith('FuelPrice.csv'): | |
filename = 'FuelPrice.csv' | |
elif f.endswith('ListOfHours.csv'): | |
filename = 'ListOfHours.csv' | |
elif f.endswith('monthlydemandrates.csv'): | |
filename = 'monthlydemandrates.csv' | |
elif f.endswith('MonthlyFee.csv'): | |
filename = 'MonthlyFee.csv' | |
elif f.endswith('monthseason.csv'): | |
filename = 'monthseason.csv' | |
with open('combined/' + filename, 'a') as export: | |
for l in h.readlines(): | |
export.write(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment