Saturday, 30 January 2021

Print CSV Content in Python Tutorial

Print CSV Content in Python Tutorial

As CSV is most common file to import and export data on web applications. So we may need to use this feature in almost our most of the apps. So I am sharing my small Python code to print CSV data into an array. May this code is helpful for someone.

We need CSV module of Python for this code to run. We used CSV module `reader` function to read CSV content in Python.

import csv

results = []
with open('test.csv', newline='') as csvfile:
    reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
    for row in reader:
        results.append(row)
print("CSV data: ", results)



More details on CSV module of Python, please follow below URL:

https://docs.python.org/3/library/csv.html

No comments:

Post a Comment

Create .ICS file using PHP code

Recently worked on creating a .ics file in PHP after a very long time, code so thought to share with everybody. Please find below the comple...