I m trying to write a function that reads files from a "deferred" directory which contains files that contain lists. Here s what the files in the deferred folder contain:
173378981 , 45000 , 343434 , 3453453 , 34534545 , 3452342 , 234234 , 42063008 , Exempted , 10000
1000014833 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Exempted , 0
1000009598 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Exempted , 0
279483421 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Exempted , 0
1000009600 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Exempted , 0
389453080 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Exempted , 0
1000009602 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , Exempted , 0
The function used to write the file(s):
def storeDeferredRecords(records):
"""docstring for createFile"""
now = datetime.datetime.now()
filename = deferredDir + / + now.strftime("%Y%m%d-%H%M%S")
f = open(filename, w )
newlist = map(lambda(x): str(x)[1:-1], records)
for item in newlist:
f.write("%s
" % item)
f.close
I need help with the function used to read the file. I was only able to write this:
def getDeferredRecords():
"""docstring for getDeferredRecords"""
infiles = [infile for infile in glob.glob(deferredDir + /* )]
<code to read the contents of each file here>
Can someone help me out? I need to read the lines and insert them into a list. This list will then be merged with records from separate CSV file.