使用CSV模块从行的中间删除CRLF

时间:2019-06-14 05:12:52

标签: python-3.x csv

我正在从Excel文件中读取一些数据并写入CSV文件。但是,在文本的中间有一些CRLF,这导致了我的问题。我该如何删除它们并仅将行尾保留在每行的末尾?

std::tuple<int, short, char> First;
std::tuple<short, float> Second;
std::tuple<int, double, short> Third;

std::tuple<int, short, char, float, double> Result = tuple_cat_unique(First,Second,Third);

电子表格中的行是这样的:

import xlrd
import csv

with xlrd.open_workbook("test.xls") as wb:
    sh = wb.sheet_by_index(0)  
    with open('output.csv', 'w', newline="") as f:   
        c = csv.writer(f,delimiter=',')
        for r in range(sh.nrows):
           c.writerow(sh.row_values(r))

但是,我要删除CRLF:

Saks Fifth Avenue: 
40; International: 6; OFF 5TH: 

0 个答案:

没有答案