![](/img/trans.png)
[英]How to import data from .txt file to a specifc excel sheet with Python?
[英]How to write an Excel sheet to a tab separated .txt file with Python
我有一個程序可以將文件從 Excel 電子表格轉換為 csv。 但是,我剛剛意識到,對於我正在處理的其他事情之一,我需要它們是制表符分隔的 .txt 文件。 我該如何轉換它踢出的內容,或者將其更改為以制表符分隔?
import openpyxl
import csv
wb = openpyxl.load_workbook('S:\\Digitization\\Metadata\\MS038_Civitan.xlsx', data_only = True)
sh1 = wb["MODS"]
with open('S:\\Digitization\\Metadata\\tools\\CSVs\\MODS.csv', 'wb') as f:
c = csv.writer(f)
for r in sh1.rows:
out_val_list = list()
for cell in r:
out_val = cell.value
if out_val == 0:
out_val = ""
out_val_list.append(out_val)
c.writerow(out_val_list)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.