You can do this very simply using pandas.

import pandas as pd

# get only the columns you want from the csv file
df = pd.read_csv(target_path + target_file, usecols=['Column Name1', 'Column Name2'])
result = df.to_dict(orient='records')

Sources:

  • pandas.read_csv
  • pandas.DataFrame.to_dict
Answer from Onel Harrison on Stack Overflow
Discussions

python - Load csv file as a dataframe - Stack Overflow
This is a noob question, but without using Pandas (pd.read) how can I import a CSV file and load it to a DataFrame object so I can call it (e.g. print (loaded_file) ) and print the contents of the ... More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
python - Does csv.DicReader() return a dictionary object? - Stack Overflow
If you look to store for calculations than will suggest to look for pandas dataframe instead of dict ... ... Given your desired output, you do not need to use dict or, consequently, csv.DictReader. Instead, just use csv.reader, which returns an iterator. More on stackoverflow.com
🌐 stackoverflow.com
How to iterate through a Pandas Dataframe / CSV?
Depending on your use case it may be faster NOT to loop through a dataframe. It is usually faster (if possible) to vectorize your operation. Nevertheless here is a basic example on how you would do it: import pandas as pd my_dict = {"name": ["Jack", "Lucy", "David"]} df = pd.DataFrame.from_dict(my_dict) for name in df["name"]: print(f"Hello {name}") More on reddit.com
🌐 r/learnpython
11
2
July 30, 2022
Struggling with using Dictreader to sort individual columns
632k members in the learnpython community. Subreddit for posting questions and asking for general advice about your python code. More on reddit.com
🌐 r/learnpython
December 6, 2016
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › using-csv-module-to-read-the-data-in-pandas
Using csv module to read the data in Pandas - GeeksforGeeks
August 5, 2021 - # importing the csv module import csv # Now let's read the file named 'auto-mpg.csv' # After reading as a dictionary convert # it to Python's list with open('auto-mpg.csv') as csvfile: mpg_data = list(csv.DictReader(csvfile)) # Let's visualize the data # We are printing only first three elements print(mpg_data[:3])
🌐
Medium
medium.com › @3valuedlogic › using-python-csv-3-dictreader-e4814ce2e44
Using Python CSV #3 — DictReader. Python’s csv module allows you to work… | by David W. Agler | Medium
December 22, 2022 - Using Python CSV #3 — DictReader Python’s csv module allows you to work with csv files (e.g., Excel spreadsheets). In previous articles (#1 and #2), I looked at two functions of thecsv module …
Find elsewhere
🌐
Sling Academy
slingacademy.com › article › python-how-to-read-a-csv-file-and-convert-it-to-a-dictionary
Python: How to read a CSV file and convert it to a dictionary - Sling Academy
import pandas as pd filename = 'example.csv' # Read CSV file into a DataFrame data_frame = pd.read_csv(filename) # Convert the DataFrame to a dictionary # Here we'll convert it to a dictionary of series for each column data_dict = data_frame.to_dict(orient='series') print(data_dict)
Top answer
1 of 2
2

csv.reader

Given your desired output, you do not need to use dict or, consequently, csv.DictReader. Instead, just use csv.reader, which returns an iterator. Then use next and list to extract headers and data respectively:

from io import StringIO
import csv

x = StringIO("""play,weather,temperature
yes,sunny,77
no,rainy,60
yes,windy,70""")

# replace x with open('file.csv', 'r')
with x as fin:
    reader = csv.reader(fin)
    headers = next(reader)  # get headers from first row
    data = list(reader)     # exhaust iterator from second row onwards

The result is a list of headers, and a list of lists for data:

print(headers)

['play', 'weather', 'temperature']

print(data)

[['yes', 'sunny', '77'],
 ['no', 'rainy', '60'],
 ['yes', 'windy', '70']]

pandas

If you are willing to use a 3rd party library, Pandas may be a better option as it handles type conversion and indexing more conveniently:

import pandas as pd

df = pd.read_csv('file.csv')

The result is a pd.DataFrame object:

print(df)

  play weather  temperature
0  yes   sunny           77
1   no   rainy           60
2  yes   windy           70

print(type(df))

<class 'pandas.core.frame.DataFrame'>
2 of 2
1

DictReader returns a file-like object. It still reads the data from the csv file in one row at a time, but the returned rows are ordered dictionaries instead of lists.

If your files is:

play,weather,temperature
yes,sunny,77
no,rainny,60
yes,windy,70

Then you can use DictReader in the following way:

with open('path/to/file.csv') as fp:
    header = fp.readline().strip().split(',')
    dreader = DictReader(fp, header)
    data = list(dreader)

In this case, data will be a list of OrderedDict objects with the mapping from the headers to each item in the row.

data
#returns:
[OrderedDict([('play', 'yes'), ('weather', 'sunny'), ('temperature', '77')]),
 OrderedDict([('play', 'no'), ('weather', 'rainny'), ('temperature', '60')]),
 OrderedDict([('play', 'yes'), ('weather', 'windy'), ('temperature', '70')])]
🌐
Python
docs.python.org › 3 › library › csv.html
csv — CSV File Reading and Writing
The csv module’s reader and writer objects read and write sequences. Programmers can also read and write data in dictionary form using the DictReader and DictWriter classes. ... The Python Enhancement Proposal which proposed this addition to Python.
🌐
Wordpress
statcompute.wordpress.com › 2018 › 10 › 21 › import-csv-as-dictionary-list
Import CSV as Dictionary List – Yet Another Blog in Statistical Computing
October 22, 2018 - from csv import DictReader from pprint import pprint ### EXAMINE 3 ROWS OF DATA with open("Downloads/nycflights.csv") as f: d = DictReader(f) l = [next(d) for i in xrange(3)] pprint(l[0]) #{'air_time': '227', # 'arr_delay': '11', # 'arr_time': '830', # 'carrier': 'UA', # 'day': '1', # 'dep_delay': '2', # 'dep_time': '517', # 'dest': 'IAH', # 'distance': '1400', # 'flight': '1545', # 'hour': '5', # 'minute': '17', # 'month': '1', # 'origin': 'EWR', # 'tailnum': 'N14228', # 'year': '2013'} A solution to address the aforementioned issue is first to import the csv file into a Pandas DataFrame and then to convert the DataFrame to the list of dictionaries, as shown in the code snippet below.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_csv.html
pandas.read_csv — pandas 3.0.4 documentation - PyData |
Read a comma-separated values (csv) file into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the online docs for IO Tools.
🌐
Linux Hint
linuxhint.com › use-python-csv-dictreader
Linux Hint – Linux Hint
December 2, 2021 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Delft Stack
delftstack.com › home › howto › python › python csv to dictionary
How to Convert CSV Into Dictionary in Python | Delft Stack
March 13, 2025 - The to_dict method is called with the orient='records' argument, which converts the DataFrame into a list of dictionaries, where each dictionary corresponds to a row in the DataFrame.
🌐
GeeksforGeeks
geeksforgeeks.org › python › load-csv-data-into-list-and-dictionary-using-python
Load CSV data into List and Dictionary using Python - GeeksforGeeks
July 12, 2025 - # importing module import csv # csv fileused id Geeks.csv filename="Geeks.csv" # opening the file using "with" # statement with open(filename,'r') as data: for line in csv.reader(data): print(line) # then data is read line by line # using csv.reader the printed # result will be in a list format # which is easy to interpret ... import csv filename ="Geeks.csv" # opening the file using "with" # statement with open(filename, 'r') as data: for line in csv.DictReader(data): print(line)
🌐
Reddit
reddit.com › r/learnpython › how to iterate through a pandas dataframe / csv?
r/learnpython on Reddit: How to iterate through a Pandas Dataframe / CSV?
July 30, 2022 -

Hi All

I have csv file named Names.csv that contains a list of student first names (Jack, Lucy, David etc) in a single column named "FName"

I also have this code below, it is quite short:

print("hello" + FName)

I want Python to print "Hello Jack" followed by "Hello Lucy" and so on and so forth, but I am not sure how. I know I need to run some sort of loop

I can load in the CSV into a Pandas dataframe using df = pd.read_csv('Names.csv') which I know, but the part involving the For Loop and Iteration is what I am struggling with

Hope you can please help?

🌐
Analytics Vidhya
analyticsvidhya.com › home › read csv files in python
Read CSV Files in Python - Analytics Vidhya
January 9, 2026 - A dictionary in how to Read CSV file in Python is like a hash table, containing keys and values. To create a dictionary, you use the dict() method with specified keys and values. If you’re working with CSV files in Python, the csv module’s .DictReader comes in handy for reading them.
🌐
GeeksforGeeks
geeksforgeeks.org › python › working-csv-files-python
Working with csv files in Python - GeeksforGeeks
We can use Pandas to write CSV files. It can done by using pd.DataFrame() function. In this example, the Pandas library is used to convert a list of dictionaries (mydict) into a DataFrame, representing tabular data.
Published   August 5, 2025
🌐
ZetCode
zetcode.com › python › csv
Python CSV - read, write CSV in Python
January 29, 2024 - The csv.reader method allows to use a different delimiter with its delimiter attribute. ... The items.csv contains values separated with '|' character. ... #!/usr/bin/python import csv with open('items.csv', 'r') as f: reader = csv.reader(f, delimiter="|") for row in reader: for e in row: print(e) The code example reads and displays data from a CSV file that uses a '|' delimiter. ... The csv.DictReader class operates like a regular reader but maps the information read into a dictionary.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › reading-csv-files-in-python
Reading CSV files in Python - GeeksforGeeks
May 25, 2026 - ... CSV column names become dictionary keys and each row stores values corresponding to those keys. The read_csv() function from the pandas library reads the CSV file and stores the data in a DataFrame...