Strip white spaces from CSV file

前端 未结 7 1241
梦谈多话
梦谈多话 2020-12-15 17:02

I need to stripe the white spaces from a CSV file that I read

import csv

aList=[]
with open(self.filename, \'r\') as f:
    reader = csv.reader(f, delimite         


        
相关标签:
7条回答
  • 2020-12-15 17:30

    There's also the embedded formatting parameter: skipinitialspace (the default is false) http://docs.python.org/2/library/csv.html#csv-fmt-params

    aList=[]
    with open(self.filename, 'r') as f:
        reader = csv.reader(f, skipinitialspace=False,delimiter=',', quoting=csv.QUOTE_NONE)
        for row in reader:
            aList.append(row)
        return(aList)
    
    0 讨论(0)
提交回复
热议问题