Python public recipes
Read a CSV file in Python
Regular read CSV file with the CSV library
For each line, use line["attributeName"]
to access the content.
Shortcut: csv.file.read
import csv
with open(file_name, mode ='r', encoding='utf-8') as file:
# reading the CSV file
csvFile = csv.DictReader(file)
# displaying the contents of the CSV file
for line in csvFile: