Python Tutorial 14: Saving and Reading Data Files With Pickle

Sdílet
Vložit
  • čas přidán 5. 09. 2024
  • You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
    / paulmcwhorter
    In this video we show step-by-step instructions on how to us Pickle in Python to save and read data files. I do not assume you are an expert, so these lessons are designed for complete beginners.
    #Python
    #Lessons
    #Programming

Komentáře • 150

  • @yehiaayoub4041
    @yehiaayoub4041 Před 3 lety +16

    I started learning programming eight months ago since I started studying to be an engineer, before then i knew nothing about programming whatsoever and it's one my drawbacks.
    I was worried it would be too hard to learn, but your videos help me A LOT, and I'm currently watching the Arduino tutorials.
    Learning a lot from you, thank you so much

  • @Pikuto
    @Pikuto Před 3 lety +14

    When there will be new Arduino lessons? , or video(s): like - "How to built drone on Arduino"?. Thanks for your lessons. Thanks for teaching us programming languages. My future work= Programmer.

  • @miken2664
    @miken2664 Před 3 lety +2

    "We are going to dump nuts" made me have to pause the video 😂. I'm just glad I didn't disrupt the rest of the class. Top lessons as always. Thanks Paul

  • @boydrogers7227
    @boydrogers7227 Před 3 lety +8

    We regret to inform you that there is no room available for folding lawn furniture as the designated space is currently filled to capacity with LEGEND!

  • @martinjones1390
    @martinjones1390 Před rokem +1

    I am legend! Discovered your set of Python tutorials yesterday and I'm already up to lesson 14. I started commercial programming in COBOL in 1975, a very different world. Any current sbc could eat those 'mainframe' monsters for breakfast in terms of processing power, memory and storage. Amazes me what we could do on a computer with 256KB memory and 240MB of hard disk. Many platforms and programming languages / environments since. I'll be buying the Arduino kit soon and will be looking at your Arduino tutorials even though the pure electronics side of it will be a mystery to me. Haven't looked at electrical theory since senior high school days, (but I did win the senior physics prize for that year so there's some hope for me yet!).

  • @patfacunla1687
    @patfacunla1687 Před 2 lety +1

    Boom!!! I can't believe it I am legend! All thanks to our great teacher Paul McWhorter!

  • @opalprestonshirley1700
    @opalprestonshirley1700 Před 3 lety +1

    Enjoyed the lesson. I had not known of Pickle, been using the open, 'w', 'r' and close. This simplifies the work. I hate that about your arrest, especially since it was the previous owner who had those but at least that's behind you. Stay safe and enjoy whatever comes your way.

  • @robinedminson6461
    @robinedminson6461 Před rokem +2

    Hey Paul. I'm really enjoying this series. I am in awe of your teaching style and have learnt a lot form your excellent skills. I previously worked through quite a bit of your Arduino classes. Now looking into Python and slowly getting there. Just completed the homework for this session. Had all the right ideas but lacking in the syntax memory department!
    Looking through my previous work helps. Even discovered how to embed a variable in an input function 🙂
    I'll follow this series through to it's conclusion. Thanks for all you do

  • @diessos
    @diessos Před rokem

    I am legend.... (and I am John Galt!). I've been programming for 45 years, and this is my first exposure to Python. I've also worked through your Arduino courses. Using that class, I'm replacing a blown stepper motor controller on a older telescope with a Nano. Very cool stuff.

  • @davidschnider1297
    @davidschnider1297 Před rokem

    Hi Paul... another excellent lesson.... I didn't do the homework... sorry... but.. I DID apply what I learned here to debug my headless GPS project by pickling the data and saving it to the SD Card .. .and then writing another little program to READ and display the data after a test drive . This helped me "see" what my GPS program was reading and processing... and I was then able to debug and complete the project. I have decided to head on back to the RPi 4 projects / lessons.... ( for now ) ... Thanks again, Paul... God bless you, Brother.

  • @pateekdarnal2256
    @pateekdarnal2256 Před 3 lety +1

    Thankyou sir for your lesson, I am proud of myself I solved pickle homework and this was the first ever homework i solved on my own. Thankyou sir I AM LEGEND may god bless you.

  • @vladmelnic-
    @vladmelnic- Před 3 lety +1

    Mandatory legend. To give myself a bit of freedom with student data, I created a student class. For writing and reading I used json. I had to convert the classes to dicts when writing, but luckily you can just apply var() to them before adding to the array. It was a bit of pain to find the var() solution, but that was actually the hardest part!
    Love the lessons. Keep up the great work!

  • @soundarrajankannan7692

    I am Legend. I just written down the Homework you said as steps like
    program one:
    1. ask how many student you have?
    2.Then ask for: student name and his average
    3. Then pickle the data
    program two:
    1.Ask which student are you interested in?
    2.Get data from pickle file
    3.Then show up his grade
    Really writing things to do helps a lot. Again, Thanks a lot. Great teaching. I am getting addicted to your videos.

  • @vinayb5076
    @vinayb5076 Před 3 lety +3

    Sir we are so excited to listen your lessons I'm in class 12 a bio student but I learnt Arduino tutorials now I'm sticking to learn python. Thank you so much sir

  • @Tivis7
    @Tivis7 Před 2 lety

    Took me around 5 hours and some back and forth with a fellow classmate, but we finally figured out a couple ways of doing it!!! The way I did it was by saving all the info in separate arrays then bunching up that info into a single array which was then pickled. That way I could say how many grades there were, the names, and the grades. After that, on the second program I just used a for loop to match the user's input to one of the names.

  • @hughpatterson1480
    @hughpatterson1480 Před 2 lety

    pickle is something my students really need to embrace so they'll be watching your fantastic lesson. Thanks Paul!

  • @qneal78710
    @qneal78710 Před 2 lety

    I have enjoyed your lesson and thankful that I came across it. I have been using a python book but came across a section where they don't explain it too well, so I went online and I found you. Thanks for giving clear instructions. I will start looking at your tutorials and also donating money

  • @jabber2824
    @jabber2824 Před 2 měsíci

    I am legend. I had to go back to lesson 3 to figure out how to address an 2-dimensional array. Very interesting lesson.

  • @airwavested
    @airwavested Před 3 lety +2

    Another Most Excellent lesson!

  • @johnplowright6421
    @johnplowright6421 Před 3 lety

    To coin your phrase: BOOM I am Legend. Very enjoyable lesson and Homework, had to review this video a few times to get the syntax right but got it working using a counter in my while loop for the number of entries instead of asking how many they want to enter.

  • @bharathr110
    @bharathr110 Před 3 lety +1

    I am Legend! Your lessons are very easy to understand. Thank you.

  • @michaelwise4040
    @michaelwise4040 Před 2 lety

    I AM LEGEND! Thank you so much Paul for these incredible videos. I am currently doing an engineering apprenticeship and hoping that learning Python will set me up for new languages and a wider career plan in the future! You are the real legend here!!

    • @paulmcwhorter
      @paulmcwhorter  Před 2 lety

      Fantastic! Also if you have not already watch my series on how to be a successful engineer, will cover every thing you need to know to land that dream job.

    • @michaelwise4040
      @michaelwise4040 Před 2 lety

      @@paulmcwhorter I will start to watch them today, looking forward to learning more skills and gaining knowledge!

  • @colepdx187
    @colepdx187 Před 2 lety

    Python is amazing. The more I delve into the online docs to get the HW assignments done, the more I discover how powerful this programming language is. I'm really looking forward to the next series about using Python with Arduino even though I no longer have the room for my workbench and had to pack my micro-controller lab away into boxes, I'll find a way to setup a small work area somewhere. Thanks for the tutorials. I'll head over to Patreon and do what I can.
    Here is a streamlined version of the bubble sort from the last assignment using one of the powerful features of the language (note the swap):
    i=0
    while (i < numGrades - 1):
    if(grades[i] < grades[i + 1]):
    grades[i], grades[i + 1] = grades[i + 1], grades[i]
    i += 1 * (i == 0) + -1 * (i > 0)
    else:
    i += 1

  • @opalprestonshirley1700

    Got her working both programs. It was a bit of a challenge but really enjoyed these two programs. Let's keep having fun.

  • @scouscoustm
    @scouscoustm Před 2 lety

    I am legend! Took a short while to figure it out but thanks to your most excellent teaching of past topics it turned out to be easier than I thought!

  • @abdullahchoudhury3080
    @abdullahchoudhury3080 Před 2 lety +1

    I AM LEGEND! Thank you Paul. When you finish your VPython series and OpenCV series, could you please do some lessons on C++. Thank you again for these great lessons.

  • @flhTK-2012
    @flhTK-2012 Před 2 lety

    Pretty neat app Pickle. We'll see after new years how easy the homework is.

  • @benhurley7565
    @benhurley7565 Před 3 lety

    I am legend! I finally got around to having a go at one of the homework assignments instead of just watching and learned a lot. Thanks.

  • @andylaurie326
    @andylaurie326 Před 3 lety

    I finally got it. Used all the stuff taught plus my brain to get it done. I learned a lot. Thank very much.

  • @larryplatzek9017
    @larryplatzek9017 Před 3 lety +1

    We are ready for more learning!

  • @georgineshkov6479
    @georgineshkov6479 Před 3 lety

    I am legend! Even made the second module to validate the entered name and if it's not existent or mistyped - reports that "No student with this name has been found!" Ah...something comes to mind with this lesson: I hope in some late lesson we get to explore what these 'wb' and 'rb' strings meaning is. Anyway - great lessons, kuddos to you Paul!

    • @harshjee4134
      @harshjee4134 Před 3 lety

      Hello georgi, i tried the same, but when i type the non-existing name, it reports 'error... student not found' 8 times (No. of students are 8), maybe it's because of for loop, or idk, can you tell me how to fix that, thanks.

  • @ulrichvantonder6719
    @ulrichvantonder6719 Před 2 lety

    I AM LEGEND, Thanks for the great tutorials, it is by far the best I have ever done!

  • @walkingtorch
    @walkingtorch Před 3 lety +1

    Ayyyyyyy it’s the man that taught me how to program an arduino uno r3

  • @ottawakravmagaacademy7013

    I AM LEGEND!!!, this was really a fun lesson. I did my homework on my own. I'm used to working with datasets so this was pretty simple for me to map out my file. Thank you for showing this and I look forward to seeing your solution next week.

  • @makergc3d
    @makergc3d Před 10 měsíci

    Apparently you're a Legend of an instructor because I Am Legend ... at least for this lession!😉 Completed assignment less than 9- minutes.

  • @spoof3974
    @spoof3974 Před 2 lety

    I AM LEGEND! So proud of myself because I was having a problems because of one misplaced parentheses.

  • @darthdaenerys
    @darthdaenerys Před 3 lety +2

    Thanks paul, I'm a legend. All bcoz of you

  • @sarahz2255
    @sarahz2255 Před 2 lety

    Love your explanation,easy to understand for beginner.

  • @MrElFRanz
    @MrElFRanz Před 3 lety

    Dear Paul, thanks to your lesosns, I could do this homework. Kind greetings.

  • @codecage9333
    @codecage9333 Před 3 lety

    I am legend! Once I finished it became quite obvious how simple it actually was to accomplish.

  • @blasterTC
    @blasterTC Před 3 lety +1

    A question, could you teach open() and close() commands in python as well, for use with basic notepad files?
    I went a bit ahead with self learning and made an automated high-score table with them, but took me way too long and i'm wondering if there is a simpler way of doing it without libraries.

  • @amayaphotos8016
    @amayaphotos8016 Před rokem

    Another Interesting Lesson

  • @mohsenr4434
    @mohsenr4434 Před 2 lety

    Great tips.. Thank you very much!

  • @LorenBurdette
    @LorenBurdette Před rokem

    Legend. Great lesson.

  • @atesotheater6536
    @atesotheater6536 Před 3 lety +1

    thank you soo much for the lesson,
    still waiting for more Arduino tutorials
    more love from martin UG

  • @keithneal7927
    @keithneal7927 Před 7 měsíci

    I'm legend, really enjoying the course

  • @advancedperformance9721
    @advancedperformance9721 Před 3 lety +1

    Thanks alot sir love it alot

  • @damsaddles9911
    @damsaddles9911 Před 3 lety

    yes sir, I am a legend, thanks to you

  • @MrXshadow1
    @MrXshadow1 Před rokem

    Paul i love u sm sir from morocco ❤️

  • @Hyfh2
    @Hyfh2 Před 2 lety

    thank you for your lesson

  • @handofash
    @handofash Před 2 lety

    I'm back after a summer hiatus in the mountains. Don't worry, I kept the Patreon flowing.

    • @paulmcwhorter
      @paulmcwhorter  Před 2 lety

      Thanks! Really appreciate the help on Patreon.

  • @taurus548
    @taurus548 Před 3 lety +1

    Sorry Paul but in your open(....) lines you introduce the term "wb" and "rb", which I understand stands for; write binary and read binary. Maybe I missed where you told us where they come from. Are they standard terms used in Python and do not need any definition. Could you expand on them a little?
    Similarly the "dt" in line 12 "for dt in bigKahuna:" where was "dt" defined??
    Many Thanks, I am enjoying the course.

    • @bigbogeyface
      @bigbogeyface Před 3 lety

      I believe "wb" and "rb" to be standard in python.
      As for "dt" in bigKahuna 🤔
      It appears to be an empty variable.
      It must update itself with each element of the bigKahuna array, while simultaneously counting which index of the array it is on, (as it continues only for the number of elements in the array).
      I'm guessing this is a pre-existing feature of variables, in for loops, in python.
      Good stuff though hey 👍 😃

    • @user-vf9dq8rn2z
      @user-vf9dq8rn2z Před rokem

      @@bigbogeyface great

  • @chernoblyat1901
    @chernoblyat1901 Před 3 lety +1

    Serious question: Is it possible to get a job like programing or robotics if your source of education is through CZcams and the internet?

    • @paulmcwhorter
      @paulmcwhorter  Před 3 lety

      Go into the interview with a heck of a project you have built. Something that shows you can do hardware and software. Show them what you can do and you have a shot.

  • @rt5hrnbfa304
    @rt5hrnbfa304 Před 3 lety

    Hello Paul, a bit unrelated but how'd the hydroponically-grown plants fared since you first showed us your greenhouse in 2019?

  • @Doakley_42
    @Doakley_42 Před 3 lety

    Hello! I'm a huge fan, and I have a suggestion!
    Could we get a video on Arduino communicating wirelessly with nRF24L01 modules? There are countless applications for them and I can't find someone that could explain it as amazing as you do!

  • @alexthebear
    @alexthebear Před 3 lety

    Thanks. The intro where you talked a little bit slower - was the best. Now it is a little bit fast.
    Because this intro is essential for all videos. I adore this phrase about coffee and jet fighters)

  • @pralaymajumdar1206
    @pralaymajumdar1206 Před 3 lety

    Learn a lot from you. Thank u sir.

  • @ricardobjorkeheim775
    @ricardobjorkeheim775 Před 3 lety

    Another Most Excellent lesson! :)

  • @U_Kamrc
    @U_Kamrc Před 3 lety

    I propose to have a tutorial on VSC debugger

  • @aman-sood
    @aman-sood Před 2 lety

    Watched this since the AI lesson 17's homework requires writing data to the disk and I have not watched the python series :P!

  • @kekekeernest8920
    @kekekeernest8920 Před 3 lety

    Greetings to you Sir Paul, when are looking forward for our next lesson on "Robotics" , and we also need a new lesson on Raspberry pi

  • @iiFoogie
    @iiFoogie Před 3 lety

    Hi Paul! I am wondering what DC barrel socket you recommend for Arduino. I’m trying to power my arduino nano. I want something small.

  • @MrTrollHobbit
    @MrTrollHobbit Před 4 měsíci

    On my 14th cup of coffee, no sugar, no sweetener today and I am about to program God in Python

  • @steveholt8991
    @steveholt8991 Před měsícem

    Did homework ok thank you.

  • @kme8134
    @kme8134 Před 2 lety

    I got it :) thank you boss!

  • @wishicouldarduino8880
    @wishicouldarduino8880 Před 3 lety

    Cool video though I haven't had much time lately .I have played around with python a little .its fun . My robot has three raspberry pi on it so I should be watching more of these.😁👍🤖🛸🛸

  • @bryankohn9660
    @bryankohn9660 Před 3 lety

    I got it. Guess "I am legend". I used some of the tricks like printing intermediate steps and I went a step further to "error check" the second program in case someone enters a student name not in the list. It gives you a error message and then asks for a new name.

  • @KamaldeenAdam
    @KamaldeenAdam Před rokem

    please sir, I didn't understood what you meant by the wright binary(wb) and the other. please help me with that or anyone can help as well.

  • @architjain1908
    @architjain1908 Před 3 lety

    I am a LEGEND!

  • @leefairfield7537
    @leefairfield7537 Před 2 lety +1

    As someone who only started python recently and watched all your other vids I think you went a bit fast with this one

  • @asakeena3258
    @asakeena3258 Před rokem

    Can any one help me with this program, I copied the code directly but every time I try to run it it tells me I can’t reference a list in the range. If anyone has had this problem I would really appreciate some help.

  • @dzeykop
    @dzeykop Před rokem

    Thank you Sir, another great lesson! Your lessons are not wasted time (#NWT) for me and that is exactly what I want! 👍

  • @RobVollmar
    @RobVollmar Před 2 lety

    I, sir, am legend.

  • @JBR7655
    @JBR7655 Před rokem

    I don’t understand the reason you dump to f, then read in at f2.

  • @graydhd8688
    @graydhd8688 Před rokem

    Pee cans? Pickle dumps? This series has taken a strange turn

  • @bigbogeyface
    @bigbogeyface Před 3 lety

    I am legend!!! 💪

  • @chrisingram7277
    @chrisingram7277 Před 3 lety

    I am legend, this seem harder than Fortran was a long, long time ago.

  • @dwaipayandutta5441
    @dwaipayandutta5441 Před 2 lety +1

    I am legend.

  • @neilausten9404
    @neilausten9404 Před 3 lety

    I have done two files as you requested and I got everything working in the way you wanted. However, in the second file I had to use len(a) to make it work. I don't think you have covered len so I guess you will do it differently. Also, I had to add a 'break' in my for command to print a final line 'Name does not exist'. Everything works fine but looking forward to your solution.

  • @erikelfsberg9414
    @erikelfsberg9414 Před 2 lety

    I'm legend, this was a tough one But I did it

  • @danielduplessis7221
    @danielduplessis7221 Před 2 lety

    I Am Legend!

  • @sandbox_beast3846
    @sandbox_beast3846 Před 3 lety

    I am also 12 student science student

  • @unablewalk4147
    @unablewalk4147 Před 3 lety

    Hey pls help me I am getting this error even though I copied whole code same
    PS D:\mann\py> & C:/Users/mann/AppData/Local/Programs/P ython/Python310-32/python.exe d:/mann/py/pickle.py
    Traceback (most recent call last):
    File "d: \mann\py\pickle.py", line 2, in import pickle
    File "d: \mann\py\pickle.py", line 9, in pickle.dump(fruits, f)
    AttributeError: partially initialized module 'pickle' h as no attribute 'dump' (most likely due to a circular i mport)

    • @davesworkplace1616
      @davesworkplace1616 Před 3 lety

      If you re-watch the video Paul cautions NOT to name your file "pickle.py" or it can cause problems. Name it "myPickle.py" instead.

  • @brucemilyko8549
    @brucemilyko8549 Před rokem

    I am Legend!

  • @HarshCreatives
    @HarshCreatives Před 2 lety +1

    I am legend

  • @mandamhlava9301
    @mandamhlava9301 Před 2 lety

    I Am Legend.

  • @Nyviv
    @Nyviv Před 3 lety

    Is it just me or is everyone here is looking forward to doing homework!!

  • @ricardobjorkeheim775
    @ricardobjorkeheim775 Před 3 lety

    I am legend :)

  • @MamtaSharma-hc9qt
    @MamtaSharma-hc9qt Před 3 lety

    I am a eighth grade student

  • @vinayb5076
    @vinayb5076 Před 3 lety +1

    I'm 2nd

  • @evanherpin6980
    @evanherpin6980 Před rokem

    I'm a legend

  • @kevinadesso825
    @kevinadesso825 Před měsícem

    I AM LEGEND😁

  • @polito-yd8fp
    @polito-yd8fp Před rokem

    I am Legend 😊

  • @kadhir5738
    @kadhir5738 Před 3 lety +6

    I'm first 🤣

  • @noweare1
    @noweare1 Před 2 lety

    I am lawnchair and I love pickels

  • @MurungiIanMugisha
    @MurungiIanMugisha Před 8 měsíci

    am a legend.

  • @snowman58able
    @snowman58able Před 3 lety

    Why didn’t you teach Jason instead of pickle

  • @williamhyrkas698
    @williamhyrkas698 Před 2 lety

    I folded yet again.

    • @paulmcwhorter
      @paulmcwhorter  Před 2 lety +1

      Dont get discouraged. It is called learning. Over time you will begin to find more success, and the harder it is to get there the more satisfying it will be when you succeed. Just dont giver up.

  • @normanmwanza8225
    @normanmwanza8225 Před 3 měsíci

    can i call you grandpa

  • @lil_muna
    @lil_muna Před 3 lety

    Sorry but I folded up like a cheap walmart lawn chair