Book Image

Raspberry Pi Zero Cookbook

Book Image

Raspberry Pi Zero Cookbook

Overview of this book

The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens up a new world for the makers out there. This book will give you expertise with the Raspberry Pi Zero, providing all the necessary recipes that will get you up and running. In this book, you will learn how to prepare your own circuits rather than buying the expensive add–ons available in the market. We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the Raspberry Pi Zero with sensors, motors, and other hardware. You will also get hands-on with interesting projects in media centers, IoT, and more.
Table of Contents (17 chapters)
Raspberry Pi Zero Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Creating a program to log and append data to a CSV file


A lot of times, we will use the Pi Zero just for data collection and transmission. We can use the power of Python to collect data on our Pi and save it to a CSV file for importing into spreadsheets or databases. Python has a CSV library for precisely this purpose, as a part of its vast collection of data manipulation tools.

Getting ready

If you are continuing with building your rpz_log_analysis.py file, then you don't need to do anything more in preparation. If you'd like to see the code up to this point in the recipe, you can find it in the /ch4/ directory as rpz_log_analysis_csv.py.

How to do it...

  1. We're going to add another feature to our Raspberry Pi Zero log analysis program. This function will write out our log data into comma separated value, or CSV, format. This is a common format for data to be exported in for migration to other data systems, such as relational databases or spreadsheets. The only thing we change in the beginning...