csv 转 excel
作者:互联网
csv 转 excel
import pandas as pd
import numpy as np
import xlwt
'''
新建excel文件
'''
myexcel = xlwt.Workbook()
mysheet = myexcel.add_sheet("testdata") #先创建一个table
path=".csv"#您要读取的文件路径
csvdata = np.loadtxt(
path,
dtype=str,
delimiter=",",#每列数据的隔开标志
usecols=(0, 1,2)#你要读取的列
#skiprows=1
)
print(csvdata)#读取出来的数据
l = 0
for line in csvdata:
r = 0
for i in line:
mysheet.write(l,r,i)
r = r + 1
l = l + 1
#保存
myexcel.save("myexcel.xls") #你要保存的excel表名
标签:读取,myexcel,excel,csvdata,import,csv 来源: https://blog.csdn.net/qq_41934789/article/details/117263279