I have a Python 3 script that reads all files with a certain name format for each month and adds them to an output (resulting in an excel CSV sheet).
#!/usr/bin/env python
import datetime
todo=[]
for year in range(2008,datetime.datetime.now().year):
for month in range(1,13):
todo += ["CoreDB-225269-REPORT_"+year+month+"01.dat"]
for name in todo:
with open("results.csv", "w") as out_file:
in_file=file(name,'r')
record=in_file.readline()
while len(record):
out_file.write(name+",\t"+record)
record=in_file.readline()
print("Read "+str(len(todo))+" files into report.")
As you seem each line of each monthly report get's added to results.csv
file. However, problem I am having is that when I open result file it only has the most recent monthly report as entries.
What happening to other months report data? Where it go!