python 同时载入多个数据文件
来源:互联网 发布:代理淘宝开店 编辑:程序博客网 时间:2024/05/24 06:40
首先将要载入的文件全放入一个文件夹,比如:D:\Traverse_document
然后写入代码:
# coding: utf-8import osimport json#给定文件夹路径,获取文件夹下所有文件的文件名称def VisitDir(path): document_file=[] for root,dirs,files in os.walk(path):#root读路径,files读路径下文件夹名字,dirs是嵌套文件夹时用,此处不需要用 for filename in files: b=os.path.join(root,filename) document_file.append(b) return document_file#将获取的文件名称传入loaddata函数,批量导入这些文件def Loaddata(document_file): list=[] for i in document_file: f=open(i) f=json.load(f) list.append(f) return listif __name__=="__main__": path="D:\\Traverse_document" document_file=VisitDir(path) print document_file #目录下所有文件列表 list=Loaddata(document_file) print list[1]["id"] #list[0]为一号文件夹内容、list[1]为第二个文件夹内容····依次类推
同理可以同时载入多个csv文件
1 0
- python 同时载入多个数据文件
- Tensorflow 同时载入多个模型
- python多个变量同时赋值
- Python同时替换多个字符串
- python同时给多个变量赋值
- windows同时安装多个Python版本
- python 同时读取多个文件
- Oracle创建多个数据文件
- ubuntu 同时安装多个版本的python
- 用python同时启动多个appium,并让多个手机同时执行脚本
- 载入数据(一行多个)
- HIVE 载入本地数据文件报错
- 一个TABLESPACE对应多个数据文件
- 分布数据文件访问多个磁盘
- 同时删除多个文件
- 同时运行多个tomcat
- 同时上传多个文件
- 同时上载多个文件
- 5
- c++_extern "C"
- linux下JDK6的安装
- Linux用户及权限基础
- 两个SVN仓库的同步----svnsync
- python 同时载入多个数据文件
- An internal error occurred during: "Launching New_configuration". Path for project must have only on
- 利用CMemDC画图的两种方法(解决绘图闪烁)
- 安卓图表控件WilliamChart使用指南
- 数据结构资料
- POJ 2935 BFS
- HashMap和Hashtable的区别
- 从源码编译nginx1.8.0 php5.6.8 mysql5.6.24
- android生命周期view事件分发的几张图片