home ~ projects ~ socials

Read A Single Line From A CSV File In Python

import csv

def read_first_line(path):
    with open(path, 'r') as _in:
        csv_reader = csv.reader(_in)
        cells = next(csv_reader)
        return cells

cells = read_first_line("read_first_line.csv")
print(cells)
Output:
['alfa', 'bravo', 'charlie']
-- end of line --