CS50P - Lecture 6 - File I/O

preview_player
Показать описание

TABLE OF CONTENTS

00:00:00 - Introduction
00:00:24 - File I/O
00:01:17 - lists
00:05:54 - open
00:13:55 - with
00:21:39 - sorted
00:29:31 - Comma-Separated Values
00:46:37 - Sort Keys
00:53:01 - Lambda Functions
00:57:13 - csv Library
01:07:49 - csv.DictReader
01:16:28 - csv.DictWriter
01:23:00 - Images, PIL library
01:31:42 - Conclusion

An introduction to programming using a language called Python. Learn how to read and write code as well as how to test and "debug" it. Designed for students with or without prior programming experience who'd like to learn Python specifically. Learn about functions, arguments, and return values (oh my!); variables and types; conditionals and Boolean expressions; and loops. Learn how to handle exceptions, find and fix bugs, and write unit tests; use third-party libraries; validate and extract data with regular expressions; model real-world entities with classes, objects, methods, and properties; and read and write files. Hands-on opportunities for lots of practice. Exercises inspired by real-world programming problems. No software required except for a web browser, or you can write code on your own PC or Mac.

Whereas CS50x itself focuses on computer science more generally as well as programming with C, Python, SQL, and JavaScript, this course, aka CS50P, is entirely focused on programming with Python. You can take CS50P before CS50x, during CS50x, or after CS50x. But for an introduction to computer science itself, you should still take CS50x!

***

HOW TO SUBSCRIBE

HOW TO TAKE CS50

HOW TO JOIN CS50 COMMUNITIES

HOW TO FOLLOW DAVID J. MALAN

***

CS50 SHOP

***

LICENSE

CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License

David J. Malan
Рекомендации по теме
Комментарии
Автор

I am not the biggest fan of coding but this guy's passion is enough to make me give it a go

shafialanower
Автор

This is probably the most intensive lecture of the course so far (I haven't watched the next ones yet).
It's a lot of information, I'll have to watch the video 3 or 4 times to process all the information properly haha.

marticus
Автор

Prior to taking cs50 course I couldn't get past week 1, had difficulty understanding problem-solving logic behind loops and functions, This course has been a breeze of fresh air, thanks to cs50 and David's eccentric enthusiasm for teaching ^^

captaingaz
Автор

with open("students.csv", "a", newline="") as file:
use this line for opening the file in order to practice writer method unless you will get extra line which will generate buggy csv file . I was facing the problem and found this solution in stack overflow and it magically worked for me .

TanzidTushar
Автор

Дуже гарні курси. Це здорово, коли є такі викладачі.

ТатьянаЛарина-шу
Автор

If someone is wondering what's the quick fix to problem at 59:20 it's that:
name, home = line.rstrip().split( ', ', 1)
split accepts two parameters, first is the separator and the second is number of times to split the text
because i passed 1 into the function that means that line will be split based on the first comma only.
Note that it won't work if you'd have more columns than two so it's generally a bad practice

penteronto
Автор

I've been trying to learn python for awhile now but I don't have access to a lot of courses because of my age, this really broke the barrier and helped me decide to fully jump into the waters and try and make a career from it. Thank you so much

atomicsprinkles
Автор

You make by far the best and most detailed and up to date courses out there. And you are the best teacher, prof. Malan! I would really appreciate if you decided to make a detailed CS50 Django course, as a sequel to this one that builds gradually, and you to be the teacher. I'm familiar with the CS50W, but it looks more like an overview than a course you can learn from scratch and become fluent after finishing. Thank you!

banka
Автор

Yes file I/O the thing you look up 70 times a day because you never memorize the syntax

sayori
Автор

Thanks for your work D/ Daivad and all harvard ! .. a student from Egypt ❤

yousefali
Автор

There is no way the students are introduced to this for the first time and even be able to grasp the concept good enough to be able to ask questions about it. I am watching it hoping to get familiar with the concepts and not trying to fully understand before moving on to the exercises since anyone who is challenged with the exercises will have to either come back to this video or search through documentations on how to get stuff done. I'd suggest you to have a go on the exercises even if you don't feel confident since as I've mentioned chances are you are gonna be doing a lot of research anyways before you can actually complete the exercise.

Sobrietyyy
Автор

Good Morning Python Family.
I late..
David is the best!
Thanks 👍

cleidysbrooks
Автор

I'm in Love with coding just because of Jay, the man of the game!

oyekanmibamidele
Автор

This lecture and the libraries one, the most enjoyable so far

decrepit
Автор

I just love this guy and this course making programming easy .

adeoyedavid
Автор

As good and passionate as always. Thanks cs50 team!

yqhanliving
Автор

if at 1:04:36 it shows ValueError too many values to unpack, you can use quotechar= ' " ' in the csv.reader function to specify that the quotes represent as a single value, so like this:
reader = csv.reader(file, quotechar= ' " ')

epitomeofrafsan
Автор

Thanks David for your passion to teach!

LuisAntonio-qltg
Автор

"I make my life more complicated for a moment" 😅 love it!

DarkAcademyUniversity
Автор

00:00:00 - Introduction
00:00:24 - File I/O
00:01:17 - lists
00:05:54 - open
00:13:55 - with
00:21:39 - sorted
00:29:31 - Comma-Separated Values
00:46:37 - Sort Keys
00:53:01 - Lambda Functions
00:57:13 - csv Library
01:02:17 - csv.reader
01:07:49 - csv.DictReader
01:14:05 - csv.writer
01:16:28 - csv.DictWriter
01:23:00 - Images, PIL library
01:31:42 - Conclusion

_schemaki_