How to Read CSV File Specific Column in Python?
Now, let's see in this tutorial of python read csv file column name. if you have question about python read csv file specific column data then I will give simple example with solution. I explained simply about python read csv file specific row.Let's get started with how to get specific row data from csv file in python.
We will use one demonstration demo.csv. ID, Name, and Email fields are included in the csv file. Then, we will use open() and DictReader() functions to read specific column data from csv file.
So let's see bellow example:
from csv import reader from csv import DictReader # open demo.csv file in read mode with open('demo.csv', 'r') as readObj: # Pass the file object to DictReader() to get the DictReader object csvDictReader = DictReader(readObj) # get over each line as a ordered dictionary for row in csvDictReader: # Get ID and Name Columns only from CSV File print(row['ID'], row['Name'])Output
1 Bhavesh Sonagra 2 Nikhil Patel 3 Piyush Kamani
It will help you....