Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40271 > unrolled thread

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

Started byMorten Engvoldsen <mortenengv@gmail.com>
First post2013-03-01 17:31 +0100
Last post2013-03-01 17:31 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Issue with continous incrementing of unbroken sequence for a entire working day Morten Engvoldsen <mortenengv@gmail.com> - 2013-03-01 17:31 +0100

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

FromMorten Engvoldsen <mortenengv@gmail.com>
Date2013-03-01 17:31 +0100
SubjectRe: Issue with continous incrementing of unbroken sequence for a entire working day
Message-ID<mailman.2738.1362155486.2939.python-list@python.org>
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@mrabarnett.plus.com>
To: python-list@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")

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web