You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

#!/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('"'))