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)
https://docs.python.org/3/library/csv.html
No comments:
Post a Comment