Python for Beginners: CSV Parsing (Part 1) - Parsing a Simple CSV File

  Рет қаралды 52,244

Scott

Scott

Күн бұрын

Part 1 of my CSV (comma-separated value) file parsing tutorial for beginners in Python.
In this video, I show you how to use Python's standard CSV library to parse and operate on simple CSV files.
Follow me on Twitter!
/ planetaryscott
Inspired by Kevin MacLeod
Link: incompetech.fi...
License: creativecommons...

Пікірлер: 44
@vincenzo3292
@vincenzo3292 3 жыл бұрын
You should make more of these videos, you have a real knack for it. I like how you explain each line of code, what it does, and why it is there. You would be surprised, but many teachers can't even do that (I have taken many professional education courses in Python, programming, etc., at major schools like the University of Washington). I have been trying to learn the csv parsing, and this video series got me over some hurdles. I work as a data analyst, doing similar work, webscraping or csv file parsing to automate mundane, time consuming stuff at work. Keep using the techy sound track, that helps to get in the space of this. Thanks!
@scott_hull
@scott_hull 3 жыл бұрын
Thanks so much, it means a lot that you took the time to write all of this. Yes, I’ll have more time soon to make more of these. Thanks for the kind words!
@dominictey2663
@dominictey2663 3 жыл бұрын
This is the best explained video that doesnt rush through the entire code in 10 secs, but properly elaborated. I was so frustrated with csv files, this helped alot.
@nadieselgirl
@nadieselgirl 3 жыл бұрын
Thank you, I needed this refresher. I had not done any real python work in a couple years and something about your presentation style brought it back pretty quickly. I hope you do more videos like this.
@connorphillips1929
@connorphillips1929 2 жыл бұрын
You have a seriously great way of teaching Python. I have been trying to understand these concepts from a variety of sources and your video is what allowed it to click for me. Please keep doing your thing!
@humanthehuman
@humanthehuman 3 жыл бұрын
3:40 "capture the hetero" had me rolling. Thanks so much for this! Helped me out a ton
@bman26793
@bman26793 2 жыл бұрын
When you explained that you don't need to have a csv file already created that python creates it automatically, I knew I was going to like and follow. Love that level of detail that so many blow off.
@jaianupamvarun5342
@jaianupamvarun5342 3 жыл бұрын
I'm glad I found this underrated video! Very informative and very precise. Thanks for providing more information in much less time. Don't give up mate! You're gonna get much bigger in next few years! Keep grinding! All the best! Gotta watch the next part lol
@petercawthorne1104
@petercawthorne1104 11 ай бұрын
Hi Scott, just gotta say that this some of the best Python-related content I've come across. Do you plan to produce any more?
@marcfacca5651
@marcfacca5651 4 жыл бұрын
Epic CSV parse build strats bro!
@christopherjspiteri
@christopherjspiteri 3 жыл бұрын
Thank you so much. Clear, to the point. Stay healthy and safe.
@Miracura
@Miracura 2 жыл бұрын
I really like the way you structured this. You did a great job of explaining each step. Great job!! Thanks for that.
@Vhix
@Vhix 3 жыл бұрын
Just what I needed, thank you!
@jackscott1097
@jackscott1097 9 ай бұрын
gee thanks scott, very informative!
@shin-channohara3202
@shin-channohara3202 2 жыл бұрын
bro great explanation keep it up we, need more videos like this on json ,xml etc ..lots of love from India
@juliabradley8917
@juliabradley8917 2 жыл бұрын
oh my god this was amazing. I love you.
@ratanghosh2767
@ratanghosh2767 3 жыл бұрын
awesome tutorial
@chrisjones1646
@chrisjones1646 3 жыл бұрын
If anyone is having problems with Null byte errors, you may need to modify the open statement with something like: with open('filename.csv', 'r', newline ='', encoding = 'utf-16') as infile:
@brendanreeves9645
@brendanreeves9645 Жыл бұрын
For those confused by line 7, "header = next(reader)": Two things are happening here: 1, the next() command is telling the csv reader to point one row down so it's now pointing at the 2nd row, skipping over the header we typically don't want to parse in our for loop, and 2, then the equality operator is storing the first line we skipped in the variable "header" in case we want it in the future.
@Mineshafts
@Mineshafts 3 жыл бұрын
Thank you so much for this video, it helped me a lot
@ivanmatejcic3776
@ivanmatejcic3776 2 жыл бұрын
Yes!! Thank you so much! This is the solution I was looking for... I used .append to add rows to the new .csv file but it was filled with excess commas and quotation marks. However, with this, that is not the case.
@muhammadfitrie7061
@muhammadfitrie7061 3 жыл бұрын
excellent video!!!!
@danielhux
@danielhux 2 жыл бұрын
Thanks for this, clears up a lot.
@khalidjj2073
@khalidjj2073 3 жыл бұрын
Hello Thanks for the great video. Question. I have 1000s of CSV files in one folder. I need your read these files one by one and extract a specific text. Finally, print file name and next to it print that extracted text. Any suggestions
@unicornminded3145
@unicornminded3145 2 жыл бұрын
thank you thank you!!!!
@joshuaoseguera9361
@joshuaoseguera9361 6 ай бұрын
Hello, thank you so much your video is so well explained! Could you please help me get out of a doubt I have about it though? It might be because english is my second lenguage, but in the for loop, it seems that it is giving you the element of each row from the column. I get a little lost because, row[0] seems to be the column[0] and the for iterates on each row, but then row is really not row it is column? I'm not sure if I'm making sense, but it looks like if the "row" in the for is both row and column.
@jeremycollum
@jeremycollum 2 жыл бұрын
Nicely explained and easy to follow. Just as a slight criticism, I found the background music a bit distracting.
@richgoo
@richgoo 2 жыл бұрын
I think you say 'go ahead and' more than lumbergh. Useful though, thanks!!
@mehmedkukavica8076
@mehmedkukavica8076 2 жыл бұрын
Seper!
@coralswank1479
@coralswank1479 3 жыл бұрын
I'm interested in how you would only "grab" or write something more specific, like only printing the students that received a C [without use of panda]
@rapidretrovenue563
@rapidretrovenue563 2 жыл бұрын
alot of these videos that go over the cvs reader are nice but perplex me in that they never go over the default location in which the csv reader reads from or how to adjust it.
@davidcooke285
@davidcooke285 3 жыл бұрын
I can print out all the rows to the screen but only the first 2 indexes to the file. do you have a forum I could post the code to for you assistance? Thanks
@scott_hull
@scott_hull 3 жыл бұрын
If you're following my tutorial, notice that in line 12 I only formatted in "Student First Name" and "Student Last Name". Just replicate the curly braces 2 more times and add in the other 2 index values to the format function.
@joanaguarin9550
@joanaguarin9550 3 жыл бұрын
How do you parse a csv without hardcoding the filename? like assigning command line arguments to variables in python
@scott_hull
@scott_hull 3 жыл бұрын
Look into the argparse Python library.
@Schnikle_fritz
@Schnikle_fritz 3 жыл бұрын
What if I wanted to write each entry in a particular column to a separate .txt file? Like, each entry gets its own .txt and all the written .txt files get saved in one folder.
@scott_hull
@scott_hull 3 жыл бұрын
You'll need to position code for that within your row-by-row for loop where you use the standard Python open function, give the file a unique name, write to it, and then close it. Maybe I'll try that in a future video.
@Schnikle_fritz
@Schnikle_fritz 3 жыл бұрын
@@scott_hull Thank you so much!! That would be awesome!!
@moviesfun9898
@moviesfun9898 2 жыл бұрын
Bro can you please help me I have a simple csv file containing name age and DOB And task is just to validate the csv file as below condition Check if the file is empty or not -Names should be String -Age should be Integer ...should not be more than 2 digits....should not be negative -Dob should be of Date time format....Dob should not be a future date.... format should be like this 10/01/1999 only If csv row conditions are satisfied then Create and send correct row to the Correct.csv Else if data is wrong such as illigal date format or integer length is more then 2 digit or something like that then just create a new csv name error.csv and send row to error.csv
@lampmanjosh
@lampmanjosh 2 жыл бұрын
What program are you using here? I'm on Windows.
@scott_hull
@scott_hull 2 жыл бұрын
PyCharm Professional Edition…there is a free community edition though.
@mabd7340
@mabd7340 3 жыл бұрын
What does parsing a file mean?
@keyurbhavsar2847
@keyurbhavsar2847 Жыл бұрын
Suggestion: Content is good but ...Do Not add Music ....Its annoying
Teaching a Toddler Household Habits: Diaper Disposal & Potty Training #shorts
00:16
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 8 МЛН
МАИНКРАФТ В РЕАЛЬНОЙ ЖИЗНИ!🌍 @Mikecrab
00:31
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 36 МЛН
Python Pandas Tutorial 4: Read Write Excel CSV File
27:03
codebasics
Рет қаралды 707 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,6 МЛН
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
16:12
Python GUI Development With PySimpleGUI
15:15
Real Python
Рет қаралды 1 МЛН
Automate Excel With Python - Python Excel Tutorial (OpenPyXL)
38:02
Tech With Tim
Рет қаралды 1,6 МЛН
Simple Calculator Project In Python (For Beginners)
8:44
Yousef Computer Science
Рет қаралды 290
Python CSV files - with PANDAS
7:59
John Watson Rooney
Рет қаралды 108 М.