python修改csv某一列 读取csv移动文件

时间:2024-10-30 07:41:31
  • import os
  • import shutil
  • import pandas as pd
  • path_csv='C:\\Users\\11982\\feiyan\\train_bboxes.csv'
  • data=pd.read_csv(path_csv)
  • # data['filename']=data['filename'].astype(str)
  • # data['filename']=data['filename'].apply(lambda x:x+'.jpg')
  • # data.to_csv(path_csv)
  • path_img='C:\\Users\\11982\\feiyan\\train'
  • ls = (path_img)
  • # # print(len(ls))
  • ans={}
  • for i in range(len(data['filename'])):
  • for j in range(len(data['filename'])):
  • if str(data['filename'][i])==str(ls[j]):
  • print(data['filename'][i])
  • # ans[i]=data['filename'][i]
  • # (path_img+'\\'+ls[j],"C:\\Users\\11982\\feiyan\\annotation\\"+ls[j])
  • (path_img+'\\'+ls[j],"C:\\Users\\11982\\feiyan\\annotation\\"+ls[j])
  • print(ls[j])