How to read one single line of csv data in Python?

后端 未结 7 1320
终归单人心
终归单人心 2020-11-28 05:04

There is a lot of examples of reading csv data using python, like this one:

import csv
with open(\'some.csv\', newline=\'\') as f:
  reader = csv.reader(f)
          


        
相关标签:
7条回答
  • 2020-11-28 05:55

    you could get just the first row like:

    with open('some.csv', newline='') as f:
      csv_reader = csv.reader(f)
      csv_headings = next(csv_reader)
      first_line = next(csv_reader)
    
    0 讨论(0)
提交回复
热议问题