added checked_numbers.csv

master
psycodad 4 years ago
parent 88cf4b9b5c
commit d5390da32f

@ -7,4 +7,13 @@ Example:
./check_postcsv.py /data/postarchiv/
(/data/postarchiv/ being the folder where you store all your csv's from post)
- /data/postarchiv/ being the folder where you store all your csv's downloaded from swisspost
- in above directory a file named 'checked_numbers.csv' is expected, with the following format:
<tracking-number>,"<Reason>"
<tracking-number>,"<Reason>"
i.e.
9960074598045013115,"Retoursendung"
This allows you to record the tracking numbers you have already checked on swisspost website, so you only have to check new ones marked with "CHECK-IT!".

@ -2,6 +2,9 @@
import csv, sys, os, glob
FNAME_CHECKED = 'checked_numbers.csv'
checked_list = {}
tr_list = []
dub_tr = []
dub_detected = 0
@ -10,12 +13,21 @@ dub_detected = 0
dirname = sys.argv[1]
print "Verwende Verzeichnis", dirname
# read checked tracking numbers
with open (os.path.join(dirname, FNAME_CHECKED)) as checked_obj:
d = csv.reader(checked_obj, delimiter=',', quoting=csv.QUOTE_ALL)
for r in d:
tr_id = int(r[0])
reason = r[1]
checked_list[tr_id] = reason
dirlist = os.listdir(dirname)
for fname in dirlist:
fbase, fext = os.path.splitext(fname)
fullfname = os.path.join(dirname, fname)
print fname, fbase, fext
if fext != ".csv":
if fext != ".csv" or fname == FNAME_CHECKED:
print "Ueberspringe Datei", fname
continue
@ -41,6 +53,9 @@ print "Dubletten erkannt:", dub_detected
print "***********************"
for dub in dub_tr:
#print dub
print dub[0], dub[4], dub[5], dub[6], dub[7], int(dub[8].replace("=", "").strip('"'))
tracking_nr = int(dub[8].replace("=", "").strip('"'))
if checked_list.has_key(tracking_nr):
print dub[0], dub[4], dub[5], dub[6], dub[7], int(dub[8].replace("=", "").strip('"')), checked_list[tracking_nr]
else:
print dub[0], dub[4], dub[5], dub[6], dub[7], int(dub[8].replace("=", "").strip('"')), "***** CHECK-IT! *****"

Loading…
Cancel
Save