如何使用多个定界符?

时间:2019-12-14 07:17:02

标签: python excel csv worksheet

因此,我正在尝试创建一种将tsv文件转换为csv的方法,但是已经使用制表符“ \ t”和delimiter ='', 有办法吗?

from xlsxwriter.workbook import Workbook

tsv_file = '1.tsv'
xlsx_file = '1.xlsx'

workbook = Workbook(xlsx_file)
worksheet = workbook.add_worksheet()

tsv_reader = csv.reader(open(tsv_file,'rt'),delimiter="\t")

for row, data in enumerate(tsv_reader):
    worksheet.write_row(row, 0, data)    

workbook.close()`

0 个答案:

没有答案