How to read a header from a CSV file using python
i tried the following script as per ur suggestion and i get an error import csv
def main():
col_name = "\\xyz-abc\Procz(abcd)\Digital"
with open('C:\\read.csv', 'rb') as inf:
reader = csv.reader(inf)
col_index = next(reader).index(col_name)
highest = max(rec[col_index] for rec in reader)
print "test"
main()
I get an error ValueError: '\\\\xyz-abc\Procz(abcd)\Digital' is not in list
please help me..
I think the scr开发者_JAVA技巧ipt is not reading the column header.
Give this a go. Prevent the back-slashes being interpreted as escape characters by using a raw string
col_name = r"\\xyz-abc\Procz(abcd)\Digital"
精彩评论