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

Discussion in 'Python' started by Morten Engvoldsen, Mar 1, 2013.

  1. 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
    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 <>
    To:
    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")
    Morten Engvoldsen, Mar 1, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vytas D.
    Replies:
    0
    Views:
    116
    Vytas D.
    Feb 28, 2013
  2. Morten Engvoldsen
    Replies:
    2
    Views:
    119
    Chris Angelico
    Feb 28, 2013
  3. Matt Jones
    Replies:
    0
    Views:
    119
    Matt Jones
    Feb 28, 2013
  4. Morten Engvoldsen
    Replies:
    1
    Views:
    103
    Rick Johnson
    Feb 28, 2013
  5. Morten Engvoldsen
    Replies:
    0
    Views:
    138
    Morten Engvoldsen
    Feb 28, 2013
Loading...

Share This Page