Project: Electronics Bash - #28 - 'Saving' the Day
Doncha hate it when you do a bunch of calculations, download a bunch of data, or generate a ton of useful python objects, only for them to vanish when your program ends? Wouldn't it be nice if there was a way to preserve data on some kind of physical media in-between program runs, so you could save and reuse data? Or even make use of data that other people had created before? If only...
Is reading and writing data from files the sexiest thing you can do with code? No. Is it one of the most useful? Oh yeah. We'll look at:
- Reading and writing plain text in files
- Reading and writing structured data using JSON
- Reading and writing raw python objects using Pickle
- Strategies to avoid re-generating data when not necessary
- How to avoid using too much web data my caching locally
This week's class had no slides.
Code
File-Helloworld
Click here to view code on GithubWith.py
Click here to view code on GithubScrambled Read
Click here to view code on GithubScrambled Tuples
Click here to view code on GithubPickle Save
Click here to view code on GithubPickle Load
Click here to view code on GithubJSON Save
Click here to view code on GithubJSON Load
Click here to view code on GithubHenry V
Click here to view code on GithubFile Existence Test
Click here to view code on GithubResources and Links
Links and Resources:
Raspberry Pi Homepage: https://www.raspberrypi.org/
Raspberry Pi OS: https://www.raspberrypi.org/downloads/
MagPi Magazine: https://magpi.raspberrypi.org/
Python Reference: https://docs.python.org/3/tutorial/index.html
Getting Started:
Raspberry Pi Imager: https://www.raspberrypi.org/downloads/
Troubleshooting Guide: https://www.raspberrypi.org/learning/troubleshooting-guide/
Display Troubleshooting: https://www.raspberrypi.org/documentation/hardware/display/troubleshooting.md
Starting w/o a Monitor: https://bit.ly/33IvKCc
Materials:
Video on Raspberry Pi Supplies: https://youtu.be/zeHvQZzkxbk
Raspberry Pi 4: https://www.adafruit.com/product/4292
Power Supp;y: https://amzn.to/2PiU6u6
MicroSD Card: https://amzn.to/2EHfHdA
MicroSD Card Reader: https://amzn.to/2EEmNiR
Micro HDMI to HDMI Cable: https://amzn.to/3jWffYW
Keyboard and Mouse: https://amzn.to/39LRX3v
Cat5 Cable: https://amzn.to/2EzoJcm
Some of the above links are Amazon affiliate links - ordering products through these links provides a small amount of support to the channel at no cost to you.