Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-03-02 Thread Morten Engvoldsen
Hi, Thanks to all.. this is great forum with so many good people. I have learnt a lot of Python from this forum. Hope one day i will learn enough that i can start answering in this forum.. :) Thanks again.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-03-01 Thread Morten Engvoldsen
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 To: python-list@python.org Cc: Date: Fri, 01 Mar 2013 14:09:43 + Subject

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-03-01 Thread MRAB
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") -- http://mail.python.org/mailman/listinfo/pytho

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-03-01 Thread Morten Engvoldsen
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

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-03-01 Thread Morten Engvoldsen
Hi, Thanks.. :) so simply i can use time.strftime("%d%-m-%y %H:%M") , and then i can compare the date -- Forwarded message -- From: Chris Angelico To: python-list@python.org Cc: Date: Fri, 1 Mar 2013 18:59:16 +1100 Subject: Re: Issue with continous incrementing o

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-03-01 Thread Chris Angelico
On Fri, Mar 1, 2013 at 6:50 PM, Morten Engvoldsen wrote: > Hi, > No i don't want user to blame when date is changed and serial number > reset when it should not. Do you think the following function will > help for this: > > import datetime as dt import pytz utc = pytz.timezone("UTC") >>>

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Morten Engvoldsen
etime will provide current local date and time, so > hopefullt the function take care > if the local clock is changed... > > -- Forwarded message -- > From: Chris Angelico > To: python-list@python.org > Cc: > Date: Fri, 1 Mar 2013 07:52:04 +1100 > Subject:

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Chris Angelico
On Fri, Mar 1, 2013 at 8:44 AM, Morten Engvoldsen wrote: > Hi, > Thanks all for suggestion... > > I am using current date as current date local time. I think > datetime.datetime will provide current local date and time, so > hopefullt the function take care > if the local clock is changed... The

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Morten Engvoldsen
-list@python.org Cc: Date: Fri, 1 Mar 2013 07:52:04 +1100 Subject: Re: Issue with continous incrementing of unbroken sequence for a entire working day On Fri, Mar 1, 2013 at 6:23 AM, John Gordon wrote: > In Morten Engvoldsen > writes: > >> But, if i save the serial_ number value in

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Rick Johnson
On Thursday, February 28, 2013 2:41:30 PM UTC-6, Morten Engvoldsen wrote: > > [...] > > def salesrecord(): >     serial_number = 0 >     sales_recrod = {'record1':'product1', > 'record2':'product2', > 'record3':'product3', > } > >     for

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Chris Angelico
On Fri, Mar 1, 2013 at 6:23 AM, John Gordon wrote: > In Morten Engvoldsen > writes: > >> But, if i save the serial_ number value in file, then how will it decide >> to reset the serial number to '1' when the batch runs on next working day. > > Name the file so that it contains the date, i.e.

Fwd: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Morten Engvoldsen
he date. Can you please show me in my example how can i achive this.. -- Forwarded message -- From: Matt Jones To: "python-list@python.org" Cc: Date: Thu, 28 Feb 2013 13:11:38 -0600 Subject: Re: Issue with continous incrementing of unbroken sequence for a entire workin

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread John Gordon
In Morten Engvoldsen writes: > But, if i save the serial_ number value in file, then how will it decide > to reset the serial number to '1' when the batch runs on next working day. Name the file so that it contains the date, i.e. "serial_numbers.2013-02-28". If the file exists, you know tha

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Rick Johnson
On Thursday, February 28, 2013 10:31:58 AM UTC-6, Morten Engvoldsen wrote: > [...] > So if the batch has 10 records and last serial number of > first batch is 10, then when the batch runs second time in > the same day, how the 'serial_number' will get the value > of 10 and then continue the serial

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Matt Jones
Store the day as well as the serial_number in your file. If the day is the same as today's day, use the serial_number, if not, use 1. At the end of you program write the current day and serial_number. *Matt Jones* On Thu, Feb 28, 2013 at 1:00 PM, Morten Engvoldsen wrote: > Hi, > thanks for yo

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Morten Engvoldsen
Hi, thanks for youe suggestion. I think i will go for your second option: # Runs this loop until killed while True serial_number = salesrecord(serial_number) But, if i save the serial_ number value in file, then how will it decide to reset the serial number to '1' when the batch runs on next

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Vytas D.
Hi, If you want to have one program running forever and printing sales_records, you would do (one of the possibilities) something like this: def salesrecord(serial_number): for i in salesrecord: print first_sales_record serial_number += 1 print serial_number return

Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread Morten Engvoldsen
Hi team, I need to run a batch of sales records and the batch has serial_number filed to store the serial number of the sales record. The serial number should be set to 1 everyday when the batch runs first time in a day and the maximum serial number could be 1000. So when the batch runs first ti