我在代码中遇到以下错误。我究竟做错了什么。谢谢。
TypeError: 'quotchar' is an invalid keyword argument for this function
这是我的方法:
def read_csv_fieldnames(filename, separator, quote):
"""
Inputs:
filename - name of CSV file
separator - character that separates fields
quote - character used to optionally quote fields
Ouput:
A list of strings corresponding to the field names in
the given CSV file.
"""
with open(filename, "rt", newline='') as csvfile:
dict_reader = csv.DictReader(csvfile,
skipinitialspace=True,
delimiter=separator,
quotchar=quote)
return dict_reader.fieldnames;
这就是我的使用方式。
print(read_csv_fieldnames("isp_csv_files/table1.csv", ",", "''"))
答案 0 :(得分:0)
一个简单的错字:quotchar
应该是quotechar
。错误消息几乎可以告诉您。