whats the difference between row and line? if i put line in csv_writer.writerow(line) it tells me line is not defined. However with row it works. Whats the difference? thank you(00:07:20 - 00:16:12) - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

whats the difference between row and line? if i put line in csv_writer.writerow(line) it tells me line is not defined. However with row it works. Whats the difference? thank you(00:07:20 - 00:16:12)
Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

In this Python Programming Tutorial, we will be learning how to work with csv files using the csv module. We will learn how to read, parse, and write to csv files. CSV stands for "Comma-Separated Values". It is a common format for storing information. Knowing how to read, parse, and wri...
In this Python Programming Tutorial, we will be learning how to work with csv files using the csv module. We will learn how to read, parse, and write to csv files. CSV stands for "Comma-Separated Values". It is a common format for storing information. Knowing how to read, parse, and write this information to files will open the door to working with a lot of data throughout the world. Let's get started.

The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-CSV


✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter -
Instagram - https://www.instagram.com/coreymschafer/

#Python

#python #python tutorial #python csv #csv module #csv file #csv files #comma-separated values #comma separated values #csv #python for beginners #corey schafer #python (programming language) #python 3 #python 3.6 #python programming #python comma-separated values #parse csv #read csv #write csv #python parsing #python basics #python csv module
somehow my csv file dump program drops extra newline character and it doesn't look "packed" like the file in , any way around this? - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

somehow my csv file dump program drops extra newline character and it doesn't look "packed" like the file in , any way around this?

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:00:40 - 00:16:12
csv = 'comma separated valued'"And what separates the values is called a delimiter. So the 'comma' is a common delimiter. But you can use just about anything. Sometimes you will see files with tab-delimited values or dashes or things like that but they are called csv files." - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

csv = 'comma separated valued'"And what separates the values is called a delimiter. So the 'comma' is a common delimiter. But you can use just about anything. Sometimes you will see files with tab-delimited values or dashes or things like that but they are called csv files."

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:01:06 - 00:16:12
I'm using VSCode to follow along with you here. At , whilst following, when attempting to print the lines of my csv file, nothing happens. The code runs, but there's no error messages or anything. I'm using Ubuntu 20.04. Any ideas why my code isn't printing the lines in my csv file? Minus the file name, what I have is exactly identical to what you have. - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

I'm using VSCode to follow along with you here. At , whilst following, when attempting to print the lines of my csv file, nothing happens. The code runs, but there's no error messages or anything. I'm using Ubuntu 20.04. Any ideas why my code isn't printing the lines in my csv file? Minus the file name, what I have is exactly identical to what you have.

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:03:29 - 00:16:12
whats the difference between row and line? if i put line in csv_writer.writerow(line) it tells me line is not defined. However with row it works. Whats the difference? thank you - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

whats the difference between row and line? if i put line in csv_writer.writerow(line) it tells me line is not defined. However with row it works. Whats the difference? thank you

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:07:20 - 00:16:12
At  it gives me an error: module 'csv' has no attribute 'writerow' - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

At it gives me an error: module 'csv' has no attribute 'writerow'

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:07:41 - 00:16:12
Love the tutorials Corey they help so much in learning Python. Just thought I would update this video because the syntax is off around . The context manager "with open('new_names', 'w') as new_file:" will return a CSV file with a blank row in-between each row. The quick fix is to add "with open('new_names', 'w', newline='') as new_file:" and the issue goes away. - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

Love the tutorials Corey they help so much in learning Python. Just thought I would update this video because the syntax is off around . The context manager "with open('new_names', 'w') as new_file:" will return a CSV file with a blank row in-between each row. The quick fix is to add "with open('new_names', 'w', newline='') as new_file:" and the issue goes away.

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:08:00 - 00:16:12
I notice that at , a lot of lines are not delimited by tabs but by spaces. Is the tab delimiter actually working or does the csv_reader make a mistake here? - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

I notice that at , a lot of lines are not delimited by tabs but by spaces. Is the tab delimiter actually working or does the csv_reader make a mistake here?

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:09:08 - 00:16:12
You can just use the writerows method at  instead of having to iterate through csv_reader in line 9, Great video, what made you use the csv module instead of pandas? - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

You can just use the writerows method at instead of having to iterate through csv_reader in line 9, Great video, what made you use the csv module instead of pandas?

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:09:28 - 00:16:12
silly question : how did you comment your lines this way? @ - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

silly question : how did you comment your lines this way? @

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:09:35 - 00:16:12
How do you do that multiple line comment at ? It's a nice trick! - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

How do you do that multiple line comment at ? It's a nice trick!

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:09:36 - 00:16:12
How do you put "#" on more than one line at the same time? ()Thank you for your answer. - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

How do you put "#" on more than one line at the same time? ()Thank you for your answer.

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:09:38 - 00:16:12
Hi i've exactly copied your code but when i let python read the "written new" csv file as you explain at around  into the video it prints "empty" lines in between the entrys. Has anybody got an idea whats wrong there? The file seems identical to my original file. Using python3, atom, win7['jane', ' doe', ' janedoe@fake.mail'][]['john', ' mayer', 'john@fake.mail'][] - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

Hi i've exactly copied your code but when i let python read the "written new" csv file as you explain at around into the video it prints "empty" lines in between the entrys. Has anybody got an idea whats wrong there? The file seems identical to my original file. Using python3, atom, win7['jane', ' doe', ' [email protected]'][]['john', ' mayer', '[email protected]'][]

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:10:00 - 00:16:12
Hi Corey, thanks for the wonderful videos. I would like to ask one thing however, at  when I try to print the same thing I get an empty pair of square brackets at the end of each line. How can I get rid of these extra square brackets? - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

Hi Corey, thanks for the wonderful videos. I would like to ask one thing however, at when I try to print the same thing I get an empty pair of square brackets at the end of each line. How can I get rid of these extra square brackets?

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:10:06 - 00:16:12
What is this cool shortcut for 'uncommend out'? @ - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

What is this cool shortcut for 'uncommend out'? @

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:10:39 - 00:16:12
dictreader of csv - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

dictreader of csv

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:11:00 - 00:16:12
Hi Corey.  In  you say that the "field names are now the keys". The thing that confuses me is .DictReader() method actually returns a list of tuples, not a dictionary and tuples don't have key - value pairs. Could you please explain .DictReader() method more in details? Thanks! - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

Hi Corey. In you say that the "field names are now the keys". The thing that confuses me is .DictReader() method actually returns a list of tuples, not a dictionary and tuples don't have key - value pairs. Could you please explain .DictReader() method more in details? Thanks!

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:11:40 - 00:16:12
At  it gives me an error: KeyError: 'e_mail' - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

At it gives me an error: KeyError: 'e_mail'

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:12:18 - 00:16:12
We don't have tab delimiter between all first names and last names. - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

We don't have tab delimiter between all first names and last names.

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:14:55 - 00:16:12
This works too:# use extrasaction='ignore' to ignore any fields not specified in fieldnameswith open('names.csv', 'r') as csv_file:csv_reader = csv.DictReader(csv_file)# newline="" prevents double spacingwith open('new_names.csv', 'w', newline="") as new_file:fieldnames = ['first_name', 'last_name']csv_writer = csv.DictWriter(new_file, fieldnames=fieldnames,delimiter = '\t',extrasaction='ignore')csv_writer.writeheader()for line in csv_reader:csv_writer.writerow(line) - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

This works too:# use extrasaction='ignore' to ignore any fields not specified in fieldnameswith open('names.csv', 'r') as csv_file:csv_reader = csv.DictReader(csv_file)# newline="" prevents double spacingwith open('new_names.csv', 'w', newline="") as new_file:fieldnames = ['first_name', 'last_name']csv_writer = csv.DictWriter(new_file, fieldnames=fieldnames,delimiter = '\t',extrasaction='ignore')csv_writer.writeheader()for line in csv_reader:csv_writer.writerow(line)

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:15:17 - 00:16:12
When I write the code out you have at  I get a new csv file except, that there are new lines added in between every old line. So the amount of columns have doubled but every other one is empty.I'm using Pycharm - community edition btw. - Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

When I write the code out you have at I get a new csv file except, that there are new lines added in between every old line. So the amount of columns have doubled but every other one is empty.I'm using Pycharm - community edition btw.

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
2017年08月10日 
00:15:42 - 00:16:12

Corey Schafer

※本サイトに掲載されているチャンネル情報や動画情報はYouTube公式のAPIを使って取得・表示しています。

Timetable

動画タイムテーブル

動画数:234件

the future spoken is my current present. Unless I'm completely desperate, I'm not hitting reddit or google/stack overflow for most roadblocks. - How to Use ChatGPT as a Powerful Tool for Programming

the future spoken is my current present. Unless I'm completely desperate, I'm not hitting reddit or google/stack overflow for most roadblocks.

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  o k t o b e r 様 
00:12:22 - 00:31:08
Good video as always😉  I remember asking that too lol - How to Use ChatGPT as a Powerful Tool for Programming

Good video as always😉 I remember asking that too lol

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  kami 様 
00:28:19 - 00:31:08
@ - pure gold, pure gold! <3 - How to Use ChatGPT as a Powerful Tool for Programming

@ - pure gold, pure gold! <3

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  ulf gjerdingen 様 
00:28:26 - 00:31:08
You almost had me there haha! ChatGPT can be wrong but it certainly wasn't wrong about those top notch resources! I massively appreciate all the uploads and I hope they keep coming supercharged with Chat GPT. Thanks to you, sentdex, techwithtim and Dennis Ivy I now know how to properly code on python, use git for version control and build a functional website. - How to Use ChatGPT as a Powerful Tool for Programming

You almost had me there haha! ChatGPT can be wrong but it certainly wasn't wrong about those top notch resources! I massively appreciate all the uploads and I hope they keep coming supercharged with Chat GPT. Thanks to you, sentdex, techwithtim and Dennis Ivy I now know how to properly code on python, use git for version control and build a functional website.

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  Uj Vag 様 
00:28:42 - 00:31:08
and it's  am here (south east asia), and idk why I'm watching a python tutorial rather than sleeping 😂 - Python Tutorial: Simulate the Powerball Lottery Using Python

and it's am here (south east asia), and idk why I'm watching a python tutorial rather than sleeping 😂

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  X 様 
00:02:49 - 00:38:56
… nice… 😂 - Python Tutorial: Simulate the Powerball Lottery Using Python

… nice… 😂

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Bartosz Turkowyd 様 
00:04:50 - 00:38:56
I've seen every Python video you've made....   first innuendo. 😜 - Python Tutorial: Simulate the Powerball Lottery Using Python

I've seen every Python video you've made.... first innuendo. 😜

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Martin Beaudry 様 
00:04:52 - 00:38:56
Man it's  am in India I am lucky to be the first one to hear your voice god bless you brother and an awesome teacher. - Python Tutorial: Simulate the Powerball Lottery Using Python

Man it's am in India I am lucky to be the first one to hear your voice god bless you brother and an awesome teacher.

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Big Samosa 様 
00:12:15 - 00:38:56
# you can also use the built-in pprint module for pretty printing dictionaries ;) - Python Tutorial: Simulate the Powerball Lottery Using Python

# you can also use the built-in pprint module for pretty printing dictionaries ;)

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Schoenling Wunderbar 様 
00:25:00 - 00:38:56
it would be very interesting to see if there could be a step function where this algorithm can simulate the increases in jackpot winnings. It’s going to be one in 292+ million of a chance that you hit it at all much less multiple times, but the code should be interesting to see. - Python Tutorial: Simulate the Powerball Lottery Using Python

it would be very interesting to see if there could be a step function where this algorithm can simulate the increases in jackpot winnings. It’s going to be one in 292+ million of a chance that you hit it at all much less multiple times, but the code should be interesting to see.

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  20 80 様 
00:27:43 - 00:38:56
A OAuth Django video would be awesome!(Applicable to all sorts of OAuth situations, not just the YouTube API.) - Python YouTube API Tutorial: Using OAuth to Access User Accounts

A OAuth Django video would be awesome!(Applicable to all sorts of OAuth situations, not just the YouTube API.)

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:07:58 - 00:43:21
At  you move the file and see some blurred miniature version of your open folders in the dock. How did you enable that? - Python YouTube API Tutorial: Using OAuth to Access User Accounts

At you move the file and see some blurred miniature version of your open folders in the dock. How did you enable that?

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:09:58 - 00:43:21
In case you are getting Error 403 ("access_denied The developer hasn’t given you access to this app") go to the OAuth consent screen and under Test Users add your email by clicking on Add Users.  You should be able to grant access after you've added User. - Python YouTube API Tutorial: Using OAuth to Access User Accounts

In case you are getting Error 403 ("access_denied The developer hasn’t given you access to this app") go to the OAuth consent screen and under Test Users add your email by clicking on Add Users. You should be able to grant access after you've added User.

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:19:36 - 00:43:21
@corey  So why did you add the join function here, when appending the video id to the list its already a list and its working for me when I pass the vid_ids directly - Python YouTube API Tutorial: Calculating the Duration of a Playlist

@corey So why did you add the join function here, when appending the video id to the list its already a list and its working for me when I pass the vid_ids directly

Python YouTube API Tutorial: Calculating the Duration of a Playlist
2020年06月11日 
00:11:24 - 00:37:38
TypeError: expected string or bytes-like object, I am taking this error in , any idea? - Python YouTube API Tutorial: Calculating the Duration of a Playlist

TypeError: expected string or bytes-like object, I am taking this error in , any idea?

Python YouTube API Tutorial: Calculating the Duration of a Playlist
2020年06月11日 
00:18:50 - 00:37:38
(I love that "Whoops that went too well"-moment at  :D) - Python Tutorial: Real World Example - Using Patreon API and Pillow to Automate Image Creation

(I love that "Whoops that went too well"-moment at :D)

Python Tutorial: Real World Example - Using Patreon API and Pillow to Automate Image Creation
2020年05月11日 
00:35:19 - 00:52:33
Read CSV - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Read CSV -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:00:56 - 00:03:20
Write CSV - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Write CSV -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:03:20 - 00:04:40
Write TSV - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Write TSV -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:04:40 - 00:06:00
Read TSV - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Read TSV -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:06:00 - 00:06:15
Write Excel - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Write Excel -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:06:15 - 00:10:42
Read Excel -  (Start at 6:15 to see installed packages) - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Read Excel - (Start at 6:15 to see installed packages)

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:10:42 - 00:12:18
Write JSON - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Write JSON -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:12:18 - 00:15:41
Read JSON - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Read JSON -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:15:41 - 00:16:59
Write SQL - - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Write SQL -

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:16:59 - 00:24:57
# Just in case:If you are using sqlite3 instead of sqlalchemy, you have to use SQL string not the table name: - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

# Just in case:If you are using sqlite3 instead of sqlalchemy, you have to use SQL string not the table name:

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:24:57 - 00:32:45
Read SQL -  (Start at 16:59 to see installed packages) - Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc

Read SQL - (Start at 16:59 to see installed packages)

Python Pandas Tutorial (Part 11): Reading/Writing Data to Different Sources - Excel, JSON, SQL, Etc
2020年04月02日 
00:24:57 - 00:32:45
Corey Ception - Live Stream - Chat, Q&A, Brews, and Coding

Corey Ception

Live Stream - Chat, Q&A, Brews, and Coding
2020年03月24日  MLittle Programming 様 
00:00:03 - 01:01:21
Ah, I missed the stream :(..  VIM! haha but seriously, I'm a recent convert to vim. It's powerful and efficient. - Live Stream - Chat, Q&A, Brews, and Coding

Ah, I missed the stream :(.. VIM! haha but seriously, I'm a recent convert to vim. It's powerful and efficient.

Live Stream - Chat, Q&A, Brews, and Coding
2020年03月24日  stuart 様 
00:02:35 - 01:01:21
Youtube premium is ad-free. - Live Stream - Chat, Q&A, Brews, and Coding

Youtube premium is ad-free.

Live Stream - Chat, Q&A, Brews, and Coding
2020年03月24日  stuart 様 
00:21:00 - 01:01:21
I knew that, but...😆 - Live Stream - Chat, Q&A, Brews, and Coding

I knew that, but...😆

Live Stream - Chat, Q&A, Brews, and Coding
2020年03月24日  Deepam Gupta 様 
00:41:25 - 01:01:21