Issue with continous incrementing of unbroken sequence for a entire working day
Morten Engvoldsen
mortenengv at gmail.com
Fri Mar 1 06:25:02 EST 2013
Hi,
I have wrote the below code for getting the serial number: look like i
am able to get correct serial number:
from datetime import date
def read_data_file():
with open("workfile.txt", 'r') as f:
for line in f.readlines():
read_data = line.split(' ')
return read_data
def write_data_file(data):
fo = open("workfile.txt", "w")
fo.write(str(data))
fo.close()
def comput_date(read_date, now_time, read_serial):
if read_date == now_time:
read_serial = int(read_serial)
return read_serial + 1
else:
read_serial = 1
return read_serial
def process_sales_record():
now_time = time.strftime("%d-%m-%y")
readdata = read_data_file()
if readdata:
read_serial = readdata[0]
read_date = readdata[1]
copute_date = comput_date(read_date, now_time, read_serial)
serial_number = copute_date
print serial_number
sales_recrod = {'record1':'product1',
'record2':'product2','record3':'product3'}
for i in sales_recrod:
print sales_recrod[i]
serial_number += 1
print serial_number
data = str(serial_number) + ' ' + now_time
writedata = write_data_file(data)
print readdata
Kindly suggest how can i improve this code now.... or is it okey in this way..
On Fri, Mar 1, 2013 at 10:42 AM, Morten Engvoldsen <mortenengv at gmail.com> wrote:
> Hi,
> Thanks.. :)
> so simply i can use time.strftime("%d%-m-%y %H:%M") , and then i can
> compare the date....
>
>
More information about the Python-list
mailing list