Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
temp analysis
#11
o my god, You are such a star man, really I am delighted to see it working so far, so now I need to assign this temperature to an int and then compare it

a massive massive thanks for that.

with open('timeTemp2.txt') as f:      
    for line in f:
        #print (line.strip())
        line = line.split(',')
        print(line[1].split() [0])
        
        temp = int (line[1].split() [0])
        print(temp)
just have a look at this chief it gives me an error,


Output:
Temperature Traceback (most recent call last): File "/Users/smacpro/Desktop/codePython.py", line 25, in <module> temp = int (line[1].split() [0]) ValueError: invalid literal for int() with base 10: 'Temperature'
what's the cause for this? I think its the header of this column? is it? how can I eliminate it?
Reply
#12
(Apr-25-2019, 04:47 PM)Simba Wrote: what's the cause for this? I think its the header of this column? is it? how can I eliminate it?
with open('timeTemp2.txt') as f:
    # Skip header
    next(f)
    for line in f:
        #print (line.strip())
        line = line.split(',')
        temp = int(line[1].split()[0])
        print(temp)
Reply
#13
OK, I got over the header problem . now there is new issues, I am sorry for being so annoying but I am just to new to python to know these things.

I am trying to see that how long it takes for the temperature to come back to the range (between 17 and 24) once it goes out of range , like if it is less than 17 then how long it took for temperature to come back in the range. any ideas how can I achieve that please.


I know that each sample of temperature in this data is taken at the interval of 30 second. so I was wondering that if somehow it can be added to give you a number like if it went out the range then took 180 second to come back in range.

I really am tankful for paying attention and helping us out.

you are a gentle man @snippst
thanks a lot for this all .

I calculated the average, I checked how many times its less than 17 how many times its over 24 and how many times its in the range (>=17 and =<24).

just the one more question, that each time the temperature goes out the range how long it takes before if comes back in the range?

really appreciate your patience and help you are providing.

hot = 0
cold=0
in_range = 0
av_temp = 0
total_lines = 0
 
with open('timeTemp2.txt') as f:
    next (f) 
    for line in f:
        
        line = line.split(',')
        line[1].split() [0] # Split each line into a list: line
        
        temp = int (line[1].split() [0])
        av_temp = av_temp+temp
        total_lines = total_lines +1
        print(temp)
        
        if temp < 17 :
            
            cold = cold + 1
            
        elif temp > 24 :
           
            hot = hot+ 1
         
        elif temp >= 17 and temp <= 24 :
            
            in_range = in_range + 1
        else:
            print ('cannot find the way to do it')
this is the code that I used so far. but can't think of way to check that how long it takes before the temperature comes back in the range.
Reply
#14
do you think I have to make counter , that will add 30(to represent 30 sec interval)into a variable. and when it jumps back to normal then don't do anything and then when it goes out then it should have a new variable and it should add 30 more in the other variable?


I am so confused over this. Any suggestions?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyspark creating temp files in /tmp folder aliyesami 1 4,822 Oct-16-2021, 05:15 PM
Last Post: aliyesami
  Help with storing temp data for each day then recording min/max in app. trthskr4 3 2,360 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  How to save Matplot chart to temp file? Morkus 2 4,436 Jun-12-2021, 10:52 AM
Last Post: Morkus
  Get system info from PI (cpu load and temp) korenron 2 2,050 Aug-04-2019, 08:45 AM
Last Post: korenron
  Temp folder creation ste1605 7 5,185 Oct-03-2018, 10:39 AM
Last Post: buran
  If/ Or if/ temp controlled fan. clueless 5 3,989 Dec-25-2017, 03:21 AM
Last Post: DeaD_EyE
  Problem with remove Temp Files karlo_ds 1 3,121 Oct-26-2017, 11:42 PM
Last Post: wavic
  How to create a value system with a temp/humidity sensor? Tacoon 2 3,405 Feb-13-2017, 03:11 PM
Last Post: Tacoon

Forum Jump:

User Panel Messages

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