Issue with continous incrementing of unbroken sequence for a entire working day
Morten Engvoldsen
mortenengv at gmail.com
Fri Mar 1 11:31:19 EST 2013
Hi,
Yes, i think checking only date is sufficient . here is my code:
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
Can you give me suggestion how can i improve this code....
---------- Forwarded message ----------
From: MRAB <python at mrabarnett.plus.com>
To: python-list at python.org
Cc:
Date: Fri, 01 Mar 2013 14:09:43 +0000
Subject: Re: Issue with continous incrementing of unbroken sequence
for a entire working day
On 2013-03-01 09:42, Morten Engvoldsen wrote:
Hi,
Thanks.. :)
so simply i can use time.strftime("%d%-m-%y %H:%M") , and then i can
compare the date....
I think you're only interested in the date, not the time of day:
time.strftime("%d-%m-%y")
More information about the Python-list
mailing list