reading csv file without for

前端 未结 8 1696
孤街浪徒
孤街浪徒 2020-12-10 04:28

I need to read a CSV file in python.

Since for last row I receive a \'NULL byte\' error I would like to avoid using for keyword but the while.

Do you know ho

8条回答
  •  抹茶落季
    2020-12-10 05:03

    not really sure what you mean, but you can always check for existence with if

    >>> reader = csv.reader("file")
    >>> for r  in reader:
    ...   if r: print r
    ...
    

    if this is not what you want, you should describe your problem more clearly by showing examples of things that doesn't work for you, including sample file format and desired output you want.

提交回复
热议问题