python下根据csv将数据集按照类别分文件夹放置
2016-06-03 13:33
429 查看
代码如下:
图片地址根据实际情况修改。
import csv import os import shutil import string csvfile = open(csvfile, 'r') data = [] for line in csvfile: data.append(list(line.strip().split(','))) for i in range(len(data)): if i == 0: continue if i>=13396: cl = data[i][1] path = pic_path + str(i) +'.png' isExists = os.path.exists(path) if(isExists): newpath = new_pic_path + cl +'/' + str(i) +'.png' shutil.copyfile(path,newpath) print 'success' else: print "not here"
相关文章推荐
- Python编程规范
- 开发利器之PyCharm
- 【leetcode】3SUM python实现
- 转 python面试题
- python 多线程 入门
- python challenge 13-16关 攻略
- 小强IT游记之新疆行
- python challenge 0-6关 攻略
- python把字典转换成json字符串
- python-module 'pymysql' has no attribute 'connect'
- 解决在Windows server 2008 安装Python2.7版本
- numpy常用函数
- Python configparser模块
- python urllib2
- python爬虫基础A
- python中的@符号的作用
- python 基本语法
- Python NLTK学习
- PYTHON 自定义异常类的使用
- Python的静态方法和类方法有什么区别