Python Tutorial 14: Saving and Reading Data Files With Pickle

Поделиться
HTML-код
  • Опубликовано: 25 май 2021
  • 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
  • НаукаНаука

Комментарии • 149

  • @yehiaayoub4041
    @yehiaayoub4041 3 года назад +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 3 года назад +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 2 года назад +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

  • @martinjones1390
    @martinjones1390 Год назад +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 2 года назад +1

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

  • @jabber2824
    @jabber2824 Месяц назад

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

  • @opalprestonshirley1700
    @opalprestonshirley1700 3 года назад +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.

  • @diessos
    @diessos Год назад

    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.

  • @robinedminson6461
    @robinedminson6461 Год назад +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

  • @davidschnider1297
    @davidschnider1297 Год назад

    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.

  • @qneal78710
    @qneal78710 Год назад

    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

  • @vladmelnic-
    @vladmelnic- 3 года назад +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!

  • @hughpatterson1480
    @hughpatterson1480 2 года назад

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

  • @pateekdarnal2256
    @pateekdarnal2256 3 года назад +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.

  • @andylaurie326
    @andylaurie326 3 года назад

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

  • @ottawakravmagaacademy7013
    @ottawakravmagaacademy7013 3 года назад

    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.

  • @scouscoustm
    @scouscoustm 2 года назад

    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!

  • @Tivis7
    @Tivis7 2 года назад

    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.

  • @boydrogers7227
    @boydrogers7227 3 года назад +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!

  • @johnplowright6421
    @johnplowright6421 2 года назад

    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.

  • @airwavested
    @airwavested 3 года назад +2

    Another Most Excellent lesson!

  • @soundarrajankannan7692
    @soundarrajankannan7692 3 года назад

    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.

  • @sarahz2255
    @sarahz2255 2 года назад

    Love your explanation,easy to understand for beginner.

  • @flhTK-2012
    @flhTK-2012 2 года назад

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

  • @ulrichvantonder6719
    @ulrichvantonder6719 2 года назад

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

  • @MrElFRanz
    @MrElFRanz 3 года назад

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

  • @larryplatzek9017
    @larryplatzek9017 3 года назад +1

    We are ready for more learning!

  • @spoof3974
    @spoof3974 2 года назад

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

  • @mohsenr4434
    @mohsenr4434 2 года назад

    Great tips.. Thank you very much!

  • @bharathr110
    @bharathr110 2 года назад +1

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

  • @vinayb5076
    @vinayb5076 3 года назад +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

  • @abdullahchoudhury3080
    @abdullahchoudhury3080 2 года назад +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.

  • @walkingtorch
    @walkingtorch 3 года назад +1

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

  • @benhurley7565
    @benhurley7565 3 года назад

    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.

  • @michaelwise4040
    @michaelwise4040 2 года назад

    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  2 года назад

      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 2 года назад

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

  • @opalprestonshirley1700
    @opalprestonshirley1700 3 года назад

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

    • @paulmcwhorter
      @paulmcwhorter  3 года назад

      Great to hear! Thanks for the comment, Opal

  • @colepdx187
    @colepdx187 2 года назад

    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

  • @darthdaenerys
    @darthdaenerys 2 года назад +2

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

  • @amayaphotos8016
    @amayaphotos8016 Год назад

    Another Interesting Lesson

  • @Hyfh2
    @Hyfh2 2 года назад

    thank you for your lesson

  • @makergc3d
    @makergc3d 8 месяцев назад

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

  • @codecage9333
    @codecage9333 3 года назад

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

  • @ricardobjorkeheim775
    @ricardobjorkeheim775 3 года назад

    Another Most Excellent lesson! :)

  • @LorenBurdette
    @LorenBurdette Год назад

    Legend. Great lesson.

  • @atesotheater6536
    @atesotheater6536 3 года назад +1

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

  • @blasterTC
    @blasterTC 3 года назад +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.

  • @pralaymajumdar1206
    @pralaymajumdar1206 3 года назад

    Learn a lot from you. Thank u sir.

  • @georgineshkov6479
    @georgineshkov6479 3 года назад

    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 3 года назад

      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.

  • @keithneal7927
    @keithneal7927 5 месяцев назад

    I'm legend, really enjoying the course

  • @damsaddles9911
    @damsaddles9911 2 года назад

    yes sir, I am a legend, thanks to you

  • @MrXshadow1
    @MrXshadow1 Год назад

    Paul i love u sm sir from morocco ❤️

  • @handofash
    @handofash 2 года назад

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

    • @paulmcwhorter
      @paulmcwhorter  2 года назад

      Thanks! Really appreciate the help on Patreon.

  • @Doakley_42
    @Doakley_42 3 года назад

    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!

  • @advancedperformance9721
    @advancedperformance9721 3 года назад +1

    Thanks alot sir love it alot

  • @iiFoogie
    @iiFoogie 3 года назад

    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.

  • @kme8134
    @kme8134 Год назад

    I got it :) thank you boss!

  • @rt5hrnbfa304
    @rt5hrnbfa304 3 года назад

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

  • @dzeykop
    @dzeykop Год назад

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

  • @MrTrollHobbit
    @MrTrollHobbit 2 месяца назад

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

  • @U_Kamrc
    @U_Kamrc 3 года назад

    I propose to have a tutorial on VSC debugger

  • @aman-sood
    @aman-sood 2 года назад

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

  • @steveholt8991
    @steveholt8991 5 дней назад

    Did homework ok thank you.

  • @KamaldeenAdam
    @KamaldeenAdam Год назад

    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.

  • @wishicouldarduino8880
    @wishicouldarduino8880 3 года назад

    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.😁👍🤖🛸🛸

  • @kekekeernest8920
    @kekekeernest8920 3 года назад

    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

  • @architjain1908
    @architjain1908 3 года назад

    I am a LEGEND!

  • @asakeena3258
    @asakeena3258 Год назад

    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.

  • @graydhd8688
    @graydhd8688 Год назад

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

  • @chernoblyat1901
    @chernoblyat1901 2 года назад +1

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

    • @paulmcwhorter
      @paulmcwhorter  2 года назад

      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.

  • @bigbogeyface
    @bigbogeyface 3 года назад

    I am legend!!! 💪

  • @bryankohn9660
    @bryankohn9660 3 года назад

    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.

  • @taurus548
    @taurus548 3 года назад +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 3 года назад

      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 Год назад

      @@bigbogeyface great

  • @chrisingram7277
    @chrisingram7277 3 года назад

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

  • @RobVollmar
    @RobVollmar 2 года назад

    I, sir, am legend.

  • @danielduplessis7221
    @danielduplessis7221 2 года назад

    I Am Legend!

  • @leefairfield7537
    @leefairfield7537 2 года назад +1

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

  • @dwaipayandutta5441
    @dwaipayandutta5441 2 года назад +1

    I am legend.

  • @erikelfsberg9414
    @erikelfsberg9414 2 года назад

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

  • @JBR7655
    @JBR7655 Год назад

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

  • @ricardobjorkeheim775
    @ricardobjorkeheim775 3 года назад

    I am legend :)

  • @mandamhlava9301
    @mandamhlava9301 2 года назад

    I Am Legend.

  • @HarshCreatives
    @HarshCreatives 2 года назад +1

    I am legend

  • @sandbox_beast3846
    @sandbox_beast3846 3 года назад

    I am also 12 student science student

  • @brucemilyko8549
    @brucemilyko8549 Год назад

    I am Legend!

  • @Nyviv
    @Nyviv 2 года назад

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

  • @unablewalk4147
    @unablewalk4147 2 года назад

    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 2 года назад

      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.

  • @vinayb5076
    @vinayb5076 3 года назад +1

    I'm 2nd

  • @neilausten9404
    @neilausten9404 3 года назад

    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.

  • @MamtaSharma-hc9qt
    @MamtaSharma-hc9qt 3 года назад

    I am a eighth grade student

  • @kadhir5738
    @kadhir5738 3 года назад +6

    I'm first 🤣

  • @alexthebear
    @alexthebear 3 года назад

    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)

  • @evanherpin6980
    @evanherpin6980 Год назад

    I'm a legend

  • @noweare1
    @noweare1 2 года назад

    I am lawnchair and I love pickels

  • @MurungiIanMugisha
    @MurungiIanMugisha 6 месяцев назад

    am a legend.

  • @polito-yd8fp
    @polito-yd8fp 10 месяцев назад

    I am Legend 😊

  • @snowman58able
    @snowman58able 3 года назад

    Why didn’t you teach Jason instead of pickle

  • @williamhyrkas698
    @williamhyrkas698 2 года назад

    I folded yet again.

    • @paulmcwhorter
      @paulmcwhorter  2 года назад +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 2 месяца назад

    can i call you grandpa

  • @lil_muna
    @lil_muna 3 года назад

    Sorry but I folded up like a cheap walmart lawn chair

  • @alexthebear
    @alexthebear 3 года назад

    i had problems with working dir
    i found this solution
    import os
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    i changes work dir to file's dir
    works good.