Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check CSV file for value
#1
I'm new to python, I'm trying to set up raspberry pi for temp sensor. I got it writing values to CSV file. But now I want to check the Value and if over 67 degrees, send out an email.
I know crontab might be the way I should do it but my main question is what code do I need to check value in CSV file
path is /home/pi/projects/temp/sensors/latest values

I know people what to know what I have but just started learning python and I really have no idea where to start on that. I can not find stuff doing a internet search or a search in the forums

Thank you
Brian
Reply
#2
Start with the csv module. That reads csv files.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
This is a good tutorial: https://www.blog.pythonlibrary.org/2014/...csv-files/
Reply
#4
CVS module won't load on the raspberry pi,
E: unable to locate package csv
Reply
#5
A poor man's csv:

with open(path_to_file) as csv_file:
    for line in csv_file:
        data = line.strip().split(',')
That will parse a basic csv file. It will have problems with quoted strings containing commas. Also, data will be a list of strings. You will need to convert the temperature to a number with int() or float().
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#6
(Sep-29-2017, 02:47 AM)Brian1210 Wrote: CVS module won't load on the raspberry pi,
E: unable to locate package csv

csv is a pure-python module that's part of python's standard lib: https://github.com/python/cpython/blob/m...Lib/csv.py

If python is installed, and is at least version 2.3, then you have csv.

What's more likely is that you misspelt it, as you did in the very post that I quoted.

*edit: my mistake, the python module adds a few things on top of a c-api: https://github.com/python/cpython/blob/m...les/_csv.c
That said, it still is almost guaranteed to be bundled with python.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  please check this i wanna use a csv file as a graph xCj11 5 1,437 Aug-25-2022, 08:19 PM
Last Post: deanhystad
  check if a file exist on the internet and get the size kucingkembar 6 1,714 Apr-16-2022, 05:09 PM
Last Post: kucingkembar
  Code to check folder and sub folders for new file and alert fioranosnake 2 1,870 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Check last time file was accessed Pavel_47 4 2,759 Jun-01-2021, 05:47 PM
Last Post: Yoriz
  How to check if a file has finished being written leocsmith 2 7,688 Apr-14-2021, 04:21 PM
Last Post: perfringo
  Check if a file exists. Pedroski55 5 3,251 Sep-08-2020, 10:01 AM
Last Post: Pedroski55
  How to check to see a dbf file is EOF ? DarkCoder2020 0 1,699 Jun-16-2020, 05:03 PM
Last Post: DarkCoder2020
  Building a script to check size of file upon creation mightyn00b 2 2,350 Apr-04-2020, 04:39 AM
Last Post: Larz60+
  MySql - Loop - CHeck File gcclinux 1 2,048 Nov-30-2019, 11:51 AM
Last Post: ThomasL
  how to check for file type in a folder SoulsKeeper 4 4,870 Sep-15-2018, 02:48 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020