程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

python converts multiple excel to csv

編輯:Python

.py directory has
1.xlsx, 2.xlsx, 3.xlsx
has a 1.txt, the content is
1
2
3
python readTake 1.txt and convert the corresponding xlsx to csv according to the content.
I now read the txt, store it in an array, and then read the array to convert xlsx. Only the last xlsx can be converted. When printing, it is 1, 2, 3, and the arrayOnly the last one, don't understand why
import numpy as np
import pandas as pd
i=0
with open('123.txt','r') as f:
for line in f.readlines():
line = line.strip().split()
i+=1
b =line[0:1]
lines = np.array(b)
print(lines)

for i in range(0,len(lines)):
print(lines[i])
data = pd.read_excel('1.xlsx','Sheet1',index_col=0)
data.to_csv('data.csv',encoding='utf-8')


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved