Read CSV Files in Python with csv.DictReader - Iterate through Rows as Dicts with Columns as Keys
HTML-код
- Опубликовано: 6 июн 2024
- 0:00 What are CSV files?
0:56 Tabular data saved from Excel spreadsheets to CSV files
1:35 CSV format is a plain-text format separated by comma delimiters
2:00 Rows and columns in CSV file formats
3:08 It is easy to write programs that can read CSV files
3:40 Import DictReader from csv in Python to read CSV rows into dictionaries
4:33 DictReader uses first row for keys of the dictionary returned for each row of values
5:23 Using the open function to establish a file handle to read a UTF-8 CSV file
5:57 For in loop over rows of a CSV file with a DictReader and print each row
8:35 Reading numerical data in a CSV file with DictReader and type casting
13:06 Find the average of a column in a CSV file in Python
14:45 Why write programs that process CSV files?
In this introductory tutorial you will learn about the CSV file format and how to write programs that make use of Python's built-in CSV library using the DictReader class. With these simple concepts, you will be able to write programs that process structured, tabular data that can be created or sourced from spreadsheet software or database software. Packages like Microsoft Excel and Google Sheets can save and produce CSV files from their Save As or Export File options. Popular database software can produce CSV files, too. When using a DictReader, all column values will be strings, and this video shows you how to intentionally convert column data to numerical data for further analysis. 3rd party libraries such as pandas will do these kinds of conversions automatically for you. Once you are comfortable with the idea of reading CSV files using this lower-level functionality, you are encouraged to make use of higher-level libraries such as pandas for day-to-day data processing and analysis.
I was in a long trouble modifying a csv file, and I used the logic of your code to solve my issue !
THANK YOU.
My god, hours of pain for that. What a relief.
Kirs, it's great tutorial - you show how things works and explain what is around. Thank you very much.
Thank you so much. I just started my journey with python and just want to learn it for personal use. I really get what you are explaining here, and my brain is already drunk with the possibilities.
I never knew that I could get excited about programming 😄
Cheers for being so thorough! Hate not understanding WHY the code I'm typing works. Now Subscribed!
Your explanation are very clear thanks for making them. It will help me alot.
Super demonstration.Thank you!
I really appreciate this. Thank you so much!
Thanks, great video !
Thank you for this very useful video!
Exactly what I need !
Simple and useful
Great thank you!
Thanks man
Cool vidéo 😍
But how i do i want to print a single line by searching by the "precipitation" value for exemple ?
But how do you do that when you want to convert different types of data in each row. Lets say one column has a boolean, another an int, and another a string?
What if I needed to take a column of a csv file and count how many times a word occurs?
If the separator is not comma, something to be done to indicate that?
Thank you!
Is the dictionary reader built in to the most recent version of python?
How does the terminal printout work? around minute 7?
what if the dictionaries are not the same in terms of [str, float ] format and some are even [str, str] format????
How can you look up key/value pairs without looping?
Can we read columns of xml file which is inside csv file in python please reply
Check out the Rainbow CSV extension for VS Code. Makes csv files more human eyeball parseable.
how can we change a number in csv without it making the csv file unreadable ?
Could you please share which theme and font you used in this video for VS Code
Shades of Purple!
@@KrisJordan thank you
How can we skip a header row in the csv file? i keep getting this:
ValueError: could not convert string to float: 'Part'
The word 'Part' is the first word in the csv file header.
did you figure this out mate?
the "next" function helps you with that.
15:00 the day Apophis collided with earth
I give u 1 sub :)
THERE IS NO NEED TO EXPLAIN A MILLION TIMES WHAT CSV´S ARE....
Your video is not good for beginners