initial import

master
psycodad 4 years ago
parent 9c9130e65a
commit 88cf4b9b5c

@ -1,3 +1,10 @@
# postabuse
Check Post's CSV export for abuse of your barcode shipping labels.
Check Post's CSV export for abuse of your barcode shipping labels.
Example:
./check_postcsv.py /data/postarchiv/
(/data/postarchiv/ being the folder where you store all your csv's from post)

@ -0,0 +1,46 @@
#!/usr/bin/python
import csv, sys, os, glob
tr_list = []
dub_tr = []
dub_detected = 0
dirname = sys.argv[1]
print "Verwende Verzeichnis", dirname
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":
print "Ueberspringe Datei", fname
continue
print "Verarbeite Datei", fullfname
with open (fullfname, 'rb') as fobj:
d = csv.reader(fobj, delimiter=';', quoting=csv.QUOTE_ALL)
# skip header
d.next()
for r in d:
#print r
tr_id = r[8].replace("=", "")
if tr_id in tr_list:
print "double detected"
dub_detected += 1
dub_tr.append(r)
print r[7], tr_id
else:
tr_list.append(tr_id)
print "***********************"
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('"'))
Loading…
Cancel
Save