From 88cf4b9b5c915f47e424746f74a673a333f42ebe Mon Sep 17 00:00:00 2001 From: psycodad Date: Mon, 22 Jun 2020 14:39:45 +0200 Subject: [PATCH] initial import --- README.md | 9 ++++++++- check_postcsv.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 check_postcsv.py diff --git a/README.md b/README.md index 9061bc7..627eea4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ # postabuse -Check Post's CSV export for abuse of your barcode shipping labels. \ No newline at end of file +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) \ No newline at end of file diff --git a/check_postcsv.py b/check_postcsv.py new file mode 100755 index 0000000..8561009 --- /dev/null +++ b/check_postcsv.py @@ -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('"')) +