read csv file

    3

    772

    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:
        
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.