UPDATED I have an 'Images' folder and inside this folder there are 2 sub folders named 18 and 19
Inside folder 18 & 19 there are images named 'final.png'
I have a location.csv file
number latitude longitude name
18 , 6.984719398 ,79.86861158 ,xyz
19 , 6.984719398 ,79.87759469 ,abc
PROBLEM : I want to convert the name from 'final.png' to 6.984719398_79.86861158_final.png
How can I write a python script or any other program to accomplish this?
Here is the code I tried
import os
import pandas as pd
import csv
df = pd.read_csv("names.csv")
for i, sub_dir in enumerate(df["number"]):
img_path = os.path.join("images", sub_dir)
new_name = df["latitude"][i] + '_' + df["longitude"][i]+"_final.png"
os.rename(os.path.join(img_path, "final.png"),
os.path.join(img_path, new_name))