Python code :
“””
filename : gprs.py
“””
import csv
start_time=csv.reader(open("start time.csv") , delimiter=' ' , quotechar='|')
"""
contains start timestamps
"""
end_time=csv.reader(open("end time.csv") , delimiter=' ' , quotechar='|')
"""
contains end timestamps
"""
"""
500 records are to be generated in single file
Name of output file is : gprs_500_records.txt
"""
for i in range(500) :
x=start_time.next()
y=end_time.next()
w=csv.writer(open("gprs_500_records"+".txt",'ab') , delimiter=' ' ,quotechar=' ' )
w.writerow([ 'unchanged part'+'|'+str(x[0])+'|'+str(x[0])+'|'+str(y[0])+'unchanged part'])
print "\n"
Note : This code can act as base code for situations where we need to generate multiple files/part of file. In this case we can store 500 records in one file only or into 500 separate files. So it depends on requirement. As we observe in this case Timestamp is variable, the variable data can be username in other scenario.
No comments:
Post a Comment