Load CSV data into List and Dictionary using Python Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Prerequisites: Working with csv files in Python CSV (Comma Separated Values) is a simple file format used to store tabular data, such as a spreadsheet or database. CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. CSV raw data is not utilizable in order to use that in our Python program it can be more beneficial if we could read and separate commas and store them in a data structure. We can convert data into lists or dictionaries or a combination of both either by using functions csv.reader and csv.dictreader or manually directly and in this article, we will see it with the help of code. Example 1: Loading CSV to list CSV File: Load CSV data into List and Dictionary Python3 # 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 Output: Load CSV data into List and Dictionary Example 2: Loading CSV to dictionary Python3 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) Output: Load CSV data into List and Dictionary Example 3: Loading CSV into list of Dictionaries Python3 from csv import DictReader # open file in read mode with open("geeks.csv", 'r') as f: dict_reader = DictReader(f) list_of_dict = list(dict_reader) print(list_of_dict) Output: Load CSV data into List and Dictionary Comment More infoAdvertise with us Next Article Load CSV data into List and Dictionary using Python R rishabhrastogi2 Follow Improve Article Tags : Python Python Programs python-csv Practice Tags : python Similar Reads Convert Dictionary to String List in Python The task of converting a dictionary to a string list in Python involves transforming the key-value pairs of the dictionary into a formatted string and storing those strings in a list. For example, consider a dictionary d = {1: 'Mercedes', 2: 'Audi', 3: 'Porsche', 4: 'Lambo'}. Converting this to a st 3 min read Convert a Dictionary to a List in Python In Python, dictionaries and lists are important data structures. Dictionaries hold pairs of keys and values, while lists are groups of elements arranged in a specific order. Sometimes, you might want to change a dictionary into a list, and Python offers various ways to do this. How to Convert a Dict 3 min read Python - Create a Dictionary using List with None Values The task of creating a dictionary from a list of keys in Python involves transforming a list of elements into a dictionary where each element becomes a key. Each key is typically assigned a default value, such as None, which can be updated later. For example, if we have a list like ["A", "B", "C"], 3 min read Convert List of Lists to Dictionary - Python We are given list of lists we need to convert it to python . For example we are given a list of lists a = [["a", 1], ["b", 2], ["c", 3]] we need to convert the list in dictionary so that the output becomes {'a': 1, 'b': 2, 'c': 3}. Using Dictionary ComprehensionUsing dictionary comprehension, we ite 3 min read Get Python Dictionary Values as List - Python We are given a dictionary where the values are lists and our task is to retrieve all the values as a single flattened list. For example, given the dictionary: d = {"a": [1, 2], "b": [3, 4], "c": [5]} the expected output is: [1, 2, 3, 4, 5]Using itertools.chain()itertools.chain() function efficiently 2 min read Dictionary keys as a list in Python In Python, we will encounter some situations where we need to extract the keys from a dictionary as a list. In this article, we will explore various easy and efficient methods to achieve this.Using list() The simplest and most efficient way to convert dictionary keys to lists is by using a built-in 2 min read Extract Dictionary Values as a Python List To extract dictionary values from a list, we iterate through each dictionary, check for the key's presence, and collect its value. The result is a list of values corresponding to the specified key across all dictionaries.For example, given data = {'a': 1, 'b': 2, 'c': 3}, the output will be [1, 2, 3 3 min read Create Dynamic Dictionary using for Loop-Python The task of creating a dynamic dictionary using a for loop in Python involves iterating through a list of keys and assigning corresponding values dynamically. This method allows for flexibility in generating dictionaries where key-value pairs are added based on specific conditions or inputs during i 3 min read Create a Dictionary with List Comprehension in Python The task of creating a dictionary with list comprehension in Python involves iterating through a sequence and generating key-value pairs in a concise manner. For example, given two lists, keys = ["name", "age", "city"] and values = ["Alice", 25, "New York"], we can pair corresponding elements using 2 min read Like