Fixed csvloop (after 1st run).
Also close file after each run to prevent ressource hoarding.
This commit is contained in:
parent
9b36336c37
commit
f8ed12e35b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
testsource
|
||||
testdest
|
||||
testdata
|
||||
usercomment.sh
|
||||
|
21
exif_rad.py
21
exif_rad.py
@ -38,22 +38,21 @@ parser.add_argument('-o', '--outdir', type=str, default='.',
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Import GeigerCounter log
|
||||
with open(args.csv, "r") as f:
|
||||
csvreader = csv.reader(filter(lambda row: row[0]!='#', f), delimiter=',', skipinitialspace=True)
|
||||
|
||||
for photo in args.photos:
|
||||
# Load Image and EXIF data
|
||||
im = Image.open(photo)
|
||||
exif_dict = piexif.load(im.info['exif'])
|
||||
photo_basename = os.path.basename(photo)
|
||||
for photo in args.photos:
|
||||
# Load Image and EXIF data
|
||||
im = Image.open(photo)
|
||||
exif_dict = piexif.load(im.info['exif'])
|
||||
photo_basename = os.path.basename(photo)
|
||||
|
||||
# Import GeigerCounter log
|
||||
with open(args.csv, "r") as f:
|
||||
csvreader = csv.reader(filter(lambda row: row[0]!='#', f), delimiter=',', skipinitialspace=True)
|
||||
|
||||
picrawtime = exif_dict['Exif'][piexif.ExifIFD.DateTimeOriginal].decode('ASCII')
|
||||
picisotime = datetime.strptime(picrawtime, "%Y:%m:%d %H:%M:%S")
|
||||
print('Processing file:', photo_basename, end='\r')
|
||||
for _, csvrawtime, csvrawcpm, _ in csvreader:
|
||||
csvisotime = datetime.fromisoformat(csvrawtime)
|
||||
|
||||
if csvisotime == picisotime:
|
||||
rad = round(float(csvrawcpm) * args.sifactor, 2)
|
||||
|
||||
@ -68,9 +67,9 @@ with open(args.csv, "r") as f:
|
||||
# be os aware and use the correct directory delimiter
|
||||
outfile = os.path.join(args.outdir, photo_basename)
|
||||
im.save(outfile, exif=exif_bytes)
|
||||
|
||||
# print output
|
||||
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(picisotime), new_comment))
|
||||
break
|
||||
else:
|
||||
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(picisotime), 'NOT FOUND!'))
|
||||
f.close()
|
||||
|
Loading…
Reference in New Issue
Block a user