python文件处理-根据txt列表将文件从其他文件夹 拷贝到指定目录
2024-10-09 07:14:09
内容涉及:路径拼接,文件拷贝,内容追加(append)
# !/usr/bin/python
# -*- coding: UTF-8 -*-
import pandas as pd
import os
import time
import scipy.misc
from shutil import copyfile
from PIL import Image
import shutil lossfile_csv = []
lossfile_img = []
for line in open("error.txt"):
csvpath = line.strip('\n')
arr = csvpath.split('/')
arr_2 = arr[3]
arr_split = arr_2.split('_')
batch_Id = arr_split[0]
Medical_Id = arr_split[1]
FOV_Id = arr_split[2]
csv_dir_path = './csv/' + batch_Id + '/' + Medical_Id + '/' + FOV_Id[:-3] + 'csv'
csv_new_path = './data_error' + '/' + batch_Id + '_' + Medical_Id + '_' + FOV_Id[:-3] + 'csv'
img_dir_path = './img/' + batch_Id + '/' + Medical_Id + '/' + 'Images/' + FOV_Id
img_new_path = './data_error' + '/' + batch_Id + '_' + Medical_Id + '_' + FOV_Id
if not os.path.exists(csv_dir_path):
print("not exit file:",csv_dir_path)
lossfile_csv.append(csv_dir_path)
continue
if not os.path.exists(img_dir_path):
print("not exit file:",img_dir_path)
lossfile_img.append(img_dir_path)
continue
shutil.copy(csv_dir_path,csv_new_path)
shutil.copy(img_dir_path,img_new_path)
print("END")
最新文章
- ICollection
- javascript 获取iframe中的dom
- First day on cnblogs,破壳日~~
- Mysql-linux下密码修改,忘记密码修改,超级管理用户修改
- PHP学习笔记:MySQL数据库的操纵
- Xamarin.Forms 现已开启对 UWP 的支持
- linux笔记:压缩解压命令gzip,gunzip,tar,zip,unzip,bzip2,bunzip2
- NewRelicAgent(CustomAnalyticEvent.cxx.o), building for iOS simulator, but linking in object file built for OSX, for architecture x8(botched)
- DataGuard相同SID物理Standby搭建
- Pyhon中的除法
- 怎样把redis编译为库,挪为己用?
- CentOS 6.5 安装realtek RTL8188CE无线网卡
- UITableView 自定义选中Cell颜色
- 安装apk程序进android
- POJ1613 147/思维题
- Linux-进程描述(2)之进程标识符进程位置与环境变量
- Postgres中的物化节点之sort节点
- Git Batch命令(转)
- Unity Shader Learning
- Object类型转换成自定义类型(向下转型)