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.dictreader or manually directly
and in this article, we will see it with the help of code.
Example 1: Loading CSV to list
Example 2: Loading CSV to dictionary
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python program to read CSV without CSV module
- How to save a Python Dictionary to a CSV File?
- Writing data from a Python List to CSV row-wise
- Create a GUI to convert CSV file into excel file using Python
- Python - Convert Dictionary Value list to Dictionary List
- Convert HTML table into CSV file in python
- Python | Convert flattened dictionary into nested dictionary
- Python | Convert nested dictionary into flattened dictionary
- Using csv module to read the data in Pandas
- Convert a NumPy array into a csv file
- Load JSON String into Pandas DataFrame
- Python - Save List to CSV
- Python program to update a dictionary with the values from a dictionary list
- How to Convert an image to NumPy array and saveit to CSV file using Python?
- Python | Read csv using pandas.read_csv()
- Convert CSV to Excel using Pandas in Python
- Convert CSV to JSON using Python
- Convert Text File to CSV using Python Pandas
- How to load and save 3D Numpy array to file using savetxt() and loadtxt() functions?
- Python | Convert a list of Tuples into Dictionary
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.