Bottom Page

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
Quote
#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

Quote
#3
This is a good tutorial: https://www.blog.pythonlibrary.org/2014/...csv-files/
Quote
#4
CVS module won't load on the raspberry pi,
E: unable to locate package csv
Quote
#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

Quote
#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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Check if a file exists. Pedroski55 5 307 Sep-08-2020, 10:01 AM
Last Post: Pedroski55
  How to check to see a dbf file is EOF ? DarkCoder2020 0 251 Jun-16-2020, 05:03 PM
Last Post: DarkCoder2020
  Building a script to check size of file upon creation mightyn00b 2 519 Apr-04-2020, 04:39 AM
Last Post: Larz60+
  MySql - Loop - CHeck File gcclinux 1 382 Nov-30-2019, 11:51 AM
Last Post: ThomasL
  how to check for file type in a folder SoulsKeeper 4 1,440 Sep-15-2018, 02:48 PM
Last Post: ichabod801
  [split] Check presence of a file pascale 25 3,531 Jul-08-2018, 12:23 PM
Last Post: pascale
  Check presence of a file Steffenwolt 8 2,023 May-25-2018, 07:04 AM
Last Post: Steffenwolt
  check if file exists. ian 6 4,298 Jul-15-2017, 09:34 AM
Last Post: wavic
  Check to see if file is submitted in correct folder DBS 9 3,852 Oct-21-2016, 07:06 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)