Open CSV file only once.

This commit is contained in:
Marcus Scholz 2020-03-01 22:37:37 +01:00
parent 849d08060f
commit 16bb735b29

View File

@ -33,19 +33,19 @@ parser.add_argument('photos', metavar='Photo', type=str, nargs='+',
args = parser.parse_args()
for photo in args.photos:
# Load Image and EXIF data
im = Image.open(photo)
exif_dict = piexif.load(im.info["exif"])
# 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")
for photo in args.photos:
# Load Image and EXIF data
im = Image.open(photo)
exif_dict = piexif.load(im.info["exif"])
print("Timestamp of image: ", picisotime)
picrawtime = exif_dict["Exif"][piexif.ExifIFD.DateTimeOriginal].decode('ASCII')
picisotime = datetime.strptime(picrawtime, "%Y:%m:%d %H:%M:%S")
# Import GeigerCounter log
with open("testdata/test.hisdb.his", "r") as f:
csvreader = csv.reader(filter(lambda row: row[0]!='#', f), delimiter=',', skipinitialspace=True)
print("Timestamp of image: ", picisotime)
for _, csvrawtime, csvrawcpm, _ in csvreader:
csvisotime = datetime.fromisoformat(csvrawtime)