编写一个函数以读取以','为分隔符的CSV文件并返回记录列表。该函数必须能够忽略双引号'“'中的','。
我的尝试-
def csvReader(filename):
records = []
for line in open(filename):
line = line.rstrip('\n') # strip '\n'
if line=='':
continue # ignore empty line
x=line.split(',')
records.append(x)
return records
预期结果-['Pete,Zelle', 'Intro to HTML, CSS', '2011']
实际结果-['"Pete', 'Zelle"', '"Intro to HTML', ' CSS"', '2011']