So I have several years of weekly CSV files that look like, with in the form YYmmdd:
file = 'C:\\rig-070103'
I am trying to read and combine them into one dataset, preferably over a range of dates. So far I have:
pieces = []
for date in range(100):
path = 'C:\\rig-YYmmdd.csv' % date
frame = pd.read_csv(path)
#frame['Date']= date
pieces.append(frame)
dataset = pd.concat(pieces, ignore_index=True)
print(dataset)
But this is giving me the error:
path = 'C:\\rig-YYmmdd.csv' % date
TypeError: not all arguments converted during string formatting
I know this has to do with how I am referencing each file, any suggestions? I would also like to create another column listing the date for each file loaded in, so 1 date repeated over all rows for each file. Any help on this is really appreciated!
Here is an example of the data:
Prov Location LSD Section Township Range Meridian ...
AB 00-00-006-29W4 0 0 6 29 4
AB 01-18-008-09W4 1 18 8 9 4
AB 05-10-008-10W4 5 10 8 10 4
AB 01-12-008-12W4 1 12 8 12 4
AB 09-23-008-26W4 9 23 8 26 4
AB 13-13-009-25W4 13 13 9 25 4
So there are a few things you're doing here. One is you need a date range where each element is a day. That day then needs to be formatted as yymmdd. Then you pull in the csv into a dataframe. Then add a coumn for the date. Then append that to a main dataframe. Here's an attempt: