everybody,
I hope you can help me with this problem. I currently have a program that reads the coordinates and date from images and writes them to a file called "test.csv".
Here you can find my current code:
IMAGE_DIRECTORY = Path("/path")
images = list(IMAGE_DIRECTORY.glob("*.jpg")) + list(IMAGE_DIRECTORY.glob("*.png"))
i= 1
date_to_latlng = {}
for image in images:
meta_data = ImageMetaData(image)
latlng = meta_data.get_lat_lng()
date = meta_data.get_date_time()
date_to_latlng[date] = [latlng, "string", "some other string", i]
i = i + 1
with open("test.csv", "w", newline="") as csvfile:
writer = csv.writer(csvfile, delimiter=" ")
for date in sorted(date_to_latlng):
writer.writerow(date_to_latlng[date])
Currently the entries are sorted by date and written to the file test.csv.
The output looks like this:
"(52.59504, -126.17413)",some string,some other string, 2
"(43.05749, -121.72245)",some string,some other string, 1
But I would like the output to look like this:
52.59504 -126.17413 some string some other string 1
43.05749 -121.72245 some string some other string 2
Each entry in the test.csv file should have an ascending numbering at the end. Furthermore, the "" quotes and the brackets () should be deleted.
Anyone have any idea how to solve this?