Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
temp analysis
#1
Hi everyone, me and my brother both started learning python about 2 months ago. we have bit understanding of C but just basics to be honest, so both of us every month set a challenge for ourselves, we done ok for the last month challenge but this month I guess we wen a bit ambitious. we decided to extract the data from a csv file and then convert it into a text file.now we want to analyse the data in this file. so the challenge that we set was to see that how many times the temperature goes below 17 degree, how many times the temperature goes above 24 degrees and each time when temperature goes out of this range(either blow 17 or above 24)how long it takes for the temperature to come back in this range. we also wanted to test that what is the average temperature. well as you can see it is clearly very ambitious specially when we just started learning python 2 months ago. but now we both came to a dead end. we don't know how to solve this its just getting like a maze. So, we decided to give up and seek help and I couldn't see any better place to ask this than this place.

please give us a helping hand with this puzzle. we are really hoping that we can get to the bottom of this riddle.
I have attached the code that we worked on from last 16 days and the txt file as-well that we extracted from the csv file but we really can't go through it anymore.
we're completly stuck.

I thank you all in anticipation.


import csv

with open ('Data.csv') as file:
    reader = 0
    reader = csv.DictReader(file)
    with open ('timeTemp2.txt', 'w') as f:
        
        
        file_ch_required = str (file.readline())

        while len(file_ch_required) > 0:
            for line in file:
                f.write(line)
            
            file_ch_required = str (file.readline())
            
    


timeTemp2 = open ('timeTemp2.txt', 'r')
for line in timeTemp2:
    #line.split(',')
    tT =  timeTemp2.readline()
    split_tT = tT.split(',')
    
    if split_tT[2] < 17 :
        cold=0
        cold = cold + 1
        
    elif split_tT[2] > 24 :
        hot = 0
        hot = hot+ 1
        
    elif split_tT[2] > 17 and tT < 24 :
         in_range = 0
         in_range = in_range +1
    else:
        print ('cannot find the way to do it')

print (cold, 'times less than 17')
print (hot, 'times more than 24')
print (in_range, 'times in range')
    
timeTemp2.close()
TXT FILE.


00:00:00,14 C,87�%,WSW,6�mph,0�mph,29.1�in,0.0�in,0.0�in,Mostly Cloudy
00:00:30,11 C,81�%,WSW,6�mph,0�mph,29.1�in,0.0�in,0.0�in,Mostly Cloudy
00:01:00,23 C,93�%,W,7�mph,0�mph,29.1�in,0.0�in,0.0�in,Mostly Cloudy
00:01:30,25 C,93�%,WSW,7�mph,0�mph,29.0�in,0.0�in,0.0�in,Mostly Cloudy
00:02:00,18 C,93�%,WSW,9�mph,0�mph,29.0�in,0.0�in,0.0�in,Light Rain Shower
00:02:30,10 C,93�%,W,9�mph,0�mph,29.0�in,0.0�in,0.0�in,Light Rain Shower
00:03:00,17 C,93�%,W,9�mph,0�mph,29.0�in,0.0�in,0.0�in,Mostly Cloudy
00:03:30,17 C,93�%,W,9�mph,0�mph,29.0�in,0.0�in,0.0�in,Light Rain Shower
00:04:00,23 C,100�%,W,8�mph,0�mph,29.0�in,0.0�in,0.0�in,Mostly Cloudy
00:04:30,26 C,100�%,W,10�mph,0�mph,29.1�in,0.0�in,0.0�in,Mostly Cloudy
00:05:00,20 C,100�%,WNW,13�mph,0�mph,29.1�in,0.0�in,0.0�in,Light Rain
00:05:30,21 C,93�%,W,10�mph,0�mph,29.1�in,0.0�in,0.0�in,Light Rain
00:06:00,25 C,93�%,W,9�mph,0�mph,29.1�in,0.0�in,0.0�in,Light Rain
00:06:30,25 C,100�%,W,13�mph,0�mph,29.1�in,0.0�in,0.0�in,Light Rain
00:07:00,27 C,93�%,W,14�mph,0�mph,29.1�in,0.0�in,0.0�in,Mostly Cloudy
00:07:30,27 C,93�%,W,13�mph,0�mph,29.1�in,0.0�in,0.0�in,Fair
00:08:00,14 C,93�%,W,15�mph,0�mph,29.1�in,0.0�in,0.0�in,Partly Cloudy
00:08:30,13 C,93�%,W,12�mph,0�mph,29.1�in,0.0�in,0.0�in,Fair
00:09:00,14 C,93�%,W,14�mph,0�mph,29.2�in,0.0�in,0.0�in,Fair
00:09:30,28 C,93�%,W,16�mph,0�mph,29.2�in,0.0�in,0.0�in,Fair
00:10:00,10 C,87�%,W,17�mph,0�mph,29.2�in,0.0�in,0.0�in,Fair
00:10:30,18 C,81�%,W,20�mph,0�mph,29.2�in,0.0�in,0.0�in,Fair
00:11:00,27 C,81�%,W,21�mph,0�mph,29.2�in,0.0�in,0.0�in,Fair / Windy
00:11:30,15 C,76�%,W,22�mph,0�mph,29.2�in,0.0�in,0.0�in,Fair / Windy
00:12:00,28 C,76�%,W,23�mph,0�mph,29.3�in,0.0�in,0.0�in,Partly Cloudy / Windy
00:12:30,17 C,70�%,W,18�mph,0�mph,29.3�in,0.0�in,0.0�in,Fair
00:13:00,23 C,70�%,W,21�mph,0�mph,29.3�in,0.0�in,0.0�in,Partly Cloudy / Windy
00:13:30,23 C,66�%,W,21�mph,0�mph,29.3�in,0.0�in,0.0�in,Mostly Cloudy / Windy
00:14:00,18 C,61�%,W,23�mph,0�mph,29.3�in,0.0�in,0.0�in,Mostly Cloudy / Windy
00:14:30,14 C,66�%,W,22�mph,33�mph,29.3�in,0.0�in,0.0�in,Mostly Cloudy / Windy
00:15:00,28 C,66�%,WSW,18�mph,0�mph,29.3�in,0.0�in,0.0�in,Mostly Cloudy
00:15:30,18 C,66�%,WSW,16�mph,30�mph,29.3�in,0.0�in,0.0�in,Showers in the Vicinity
00:16:00,29 C,61�%,W,18�mph,32�mph,29.3�in,0.0�in,0.0�in,Mostly Cloudy
00:16:30,21 C,70�%,WSW,17�mph,29�mph,29.3�in,0.0�in,0.0�in,Light Rain
00:17:00,12 C,70�%,WSW,16�mph,30�mph,29.3�in,0.0�in,0.0�in,Light Rain
00:17:30,22 C,76�%,WSW,17�mph,0�mph,29.3�in,0.0�in,0.0�in,Light Rain
00:18:00,22 C,87�%,WSW,18�mph,38�mph,29.3�in,0.0�in,0.0�in,Light Rain
00:18:30,12 C,93�%,WSW,20�mph,35�mph,29.3�in,0.0�in,0.0�in,Light Rain
00:19:00,24 C,87�%,W,25�mph,0�mph,29.3�in,0.0�in,0.0�in,Light Rain / Windy
00:19:30,28 C,93�%,W,31�mph,43�mph,29.3�in,0.0�in,0.0�in,Light Rain / Windy
Reply


Messages In This Thread
temp analysis - by Simba - Apr-24-2019, 07:08 PM
RE: temp analysis - by Larz60+ - Apr-24-2019, 07:15 PM
RE: temp analysis - by Simba - Apr-24-2019, 07:33 PM
RE: temp analysis - by snippsat - Apr-24-2019, 07:43 PM
RE: temp analysis - by Simba - Apr-24-2019, 09:56 PM
RE: temp analysis - by Larz60+ - Apr-24-2019, 11:10 PM
RE: temp analysis - by Simba - Apr-25-2019, 03:17 PM
RE: temp analysis - by snippsat - Apr-25-2019, 03:23 PM
RE: temp analysis - by Simba - Apr-25-2019, 03:37 PM
RE: temp analysis - by snippsat - Apr-25-2019, 04:08 PM
RE: temp analysis - by Simba - Apr-25-2019, 04:47 PM
RE: temp analysis - by snippsat - Apr-25-2019, 05:40 PM
RE: temp analysis - by Simba - Apr-25-2019, 06:25 PM
RE: temp analysis - by Simba - Apr-25-2019, 09:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Deleting Windows temp folder Raysz 7 532 Apr-02-2024, 12:36 PM
Last Post: Raysz
  pyspark creating temp files in /tmp folder aliyesami 1 5,115 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,460 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  How to save Matplot chart to temp file? Morkus 2 4,582 Jun-12-2021, 10:52 AM
Last Post: Morkus
  Get system info from PI (cpu load and temp) korenron 2 2,118 Aug-04-2019, 08:45 AM
Last Post: korenron
  Temp folder creation ste1605 7 5,351 Oct-03-2018, 10:39 AM
Last Post: buran
  If/ Or if/ temp controlled fan. clueless 5 4,073 Dec-25-2017, 03:21 AM
Last Post: DeaD_EyE
  Problem with remove Temp Files karlo_ds 1 3,180 Oct-26-2017, 11:42 PM
Last Post: wavic
  How to create a value system with a temp/humidity sensor? Tacoon 2 3,472 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