python实现读Excel写入.txt
2017-05-14 14:17
543 查看
因为今天要用到把Excel中的数据写入到.txt文件中,所以简单的写了个代码:import numpy as np
import xlrd #打开excel文件
data= xlrd.open_workbook('./sudata/ng.xls')#打开Excel文件读取数据
sh=data.sheet_by_name("Sheet1")##通过工作簿名称获取
print sh.nrows#行数 5820
print sh.ncols#列数 2
n=0
i=0
file=open("ng.txt","w")
for n in range(sh.nrows):
for i in range(sh.ncols):
text=sh.cell_value(n,i).encode('utf-8')
file.write(text)
file.write('\n')
import xlrd #打开excel文件
data= xlrd.open_workbook('./sudata/ng.xls')#打开Excel文件读取数据
sh=data.sheet_by_name("Sheet1")##通过工作簿名称获取
print sh.nrows#行数 5820
print sh.ncols#列数 2
n=0
i=0
file=open("ng.txt","w")
for n in range(sh.nrows):
for i in range(sh.ncols):
text=sh.cell_value(n,i).encode('utf-8')
file.write(text)
file.write('\n')
相关文章推荐
- python实现读Excel写入.txt的方法
- Python实现将txt中的文件逐行导出并且写入excle
- 【Python小工具】Python实现批量解析PDF文件提取内容并写入到Excel中
- Python读取txt内容写入xls格式excel中的方法
- 使用Python通过win32 COM实现Excel的写入与保存
- python 将txt内容写入excel
- python实战之实现excel读取、统计、写入的示例讲解
- Python中xlrd、xlwt、xlutils模块,实现在Excel读取和写入数据
- Python实现读写sqlite3数据库并将统计数据写入Excel的方法示例
- python读取txt数据写入excel
- python将文件夹里所有的txt文件内容写入excel
- Python使用win32 COM实现Excel的写入与保存功能示例
- python实战之实现excel读取、统计、写入
- Python读取txt内容写入xlsx格式的excel中
- python 3.5实现检测路由器流量并写入txt的方法实例
- 基于python实现在excel中读取与生成随机数写入excel中
- Python实现读取txt文件并转换为excel的方法示例
- Python实现自定义顺序、排列写入数据到Excel的方法
- Python实现将json文件中向量写入Excel的方法
- python实现读取excel写入mysql的小工具详解