2017-07-06 42 views
-2

我有一個Excel工作表與列WIRTE信息與標識符

IdNr Filename rep_cke file_description 
10  5432.txt rutine "information from txt file (5432.txt)" 
20  5683.txt rutine "information from txt file (5683.txt)" 

現在是有使用Python寫從文本文件到的所有信息的方式爲XLS表中匹配文件名的相應單元格? 什麼我來這麼票價

def main(): 
    file = open("51712640_Rutine.txt", "r") 
    lines = file.readlines() 
    file.close() 
    print("Txt file read") 
    #print(lines) 


main() 

csv_file = open("bakgrunnsData.csv") 
csv_reader = csv.reader(csv_file, delimiter=";") 

for row in csv_reader: 
    print (row[1]) 

csv_file.close() 
+0

當然有。你有嘗試過嗎? – SiHa

+0

我試着讀通過txt文件,製作位列表並寫入電子表格。這似乎只覆蓋everthing其他 –

+0

將是非常好的一些提示去:) –

回答

0

Python有一個內置的csv模塊。如果您可以將xls文件轉換爲csv,這應該足夠好。

或者,您可以使用pandas庫來實現更高級的功能。