Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
temp analysis
#10
The file is mess up(Unicode) from whatever source you get it from or saving done be you.
Try to work and save all with utf-8 as encoding.
Can fix data.
with open ('Data.txt', encoding='utf-8') as f,open('new_data.txt', 'w') as f_out:
    fixed_data = f.read().replace('�', '')
    f_out.write(fixed_data) 
Now is new data okay.
with open('new_data.txt') as f:
    for line in f:
        print(line.strip())
Output:
Time,Temperature,Humidity,Wind,Wind Speed,Wind Gust,Pressure,Precip.,Precip Accum,Condition 00:00:00,14 C,87%,WSW,6mph,0mph,29.1in,0.0in,0.0in,Mostly Cloudy 00:00:30,11 C,81%,WSW,6mph,0mph,29.1in,0.0in,0.0in,Mostly Cloudy 00:01:00,23 C,93%,W,7mph,0mph,29.1in,0.0in,0.0in,Mostly Cloudy 00:01:30,25 C,93%,WSW,7mph,0mph,29.0in,0.0in,0.0in,Mostly Cloudy 00:02:00,18 C,93%,WSW,9mph,0mph,29.0in,0.0in,0.0in,Light Rain Shower 00:02:30,10 C,93%,W,9mph,0mph,29.0in,0.0in,0.0in,Light Rain Shower 00:03:00,17 C,93%,W,9mph,0mph,29.0in,0.0in,0.0in,Mostly Cloudy 00:03:30,17 C,93%,W,9mph,0mph,29.0in,0.0in,0.0in,Light Rain Shower 00:04:00,23 C,100%,W,8mph,0mph,29.0in,0.0in,0.0in,Mostly Cloudy 00:04:30,26 C,100%,W,10mph,0mph,29.1in,0.0in,0.0in,Mostly Cloudy 00:05:00,20 C,100%,WNW,13mph,0mph,29.1in,0.0in,0.0in,Light Rain 00:05:30,21 C,93%,W,10mph,0mph,29.1in,0.0in,0.0in,Light Rain 00:06:00,25 C,93%,W,9mph,0mph,29.1in,0.0in,0.0in,Light Rain 00:06:30,25 C,100%,W,13mph,0mph,29.1in,0.0in,0.0in,Light Rain 00:07:00,27 C,93%,W,14mph,0mph,29.1in,0.0in,0.0in,Mostly Cloudy 00:07:30,27 C,93%,W,13mph,0mph,29.1in,0.0in,0.0in,Fair 00:08:00,14 C,93%,W,15mph,0mph,29.1in,0.0in,0.0in,Partly Cloudy 00:08:30,13 C,93%,W,12mph,0mph,29.1in,0.0in,0.0in,Fair 00:09:00,14 C,93%,W,14mph,0mph,29.2in,0.0in,0.0in,Fair 00:09:30,28 C,93%,W,16mph,0mph,29.2in,0.0in,0.0in,Fair 00:10:00,10 C,87%,W,17mph,0mph,29.2in,0.0in,0.0in,Fair 00:10:30,18 C,81%,W,20mph,0mph,29.2in,0.0in,0.0in,Fair 00:11:00,27 C,81%,W,21mph,0mph,29.2in,0.0in,0.0in,Fair / Windy 00:11:30,15 C,76%,W,22mph,0mph,29.2in,0.0in,0.0in,Fair / Windy 00:12:00,28 C,76%,W,23mph,0mph,29.3in,0.0in,0.0in,Partly Cloudy / Windy 00:12:30,17 C,70%,W,18mph,0mph,29.3in,0.0in,0.0in,Fair 00:13:00,23 C,70%,W,21mph,0mph,29.3in,0.0in,0.0in,Partly Cloudy / Windy 00:13:30,23 C,66%,W,21mph,0mph,29.3in,0.0in,0.0in,Mostly Cloudy / Windy 00:14:00,18 C,61%,W,23mph,0mph,29.3in,0.0in,0.0in,Mostly Cloudy / Windy 00:14:30,14 C,66%,W,22mph,33mph,29.3in,0.0in,0.0in,Mostly Cloudy / Windy 00:15:00,28 C,66%,WSW,18mph,0mph,29.3in,0.0in,0.0in,Mostly Cloudy 00:15:30,18 C,66%,WSW,16mph,30mph,29.3in,0.0in,0.0in,Showers in the Vicinity 00:16:00,29 C,61%,W,18mph,32mph,29.3in,0.0in,0.0in,Mostly Cloudy 00:16:30,21 C,70%,WSW,17mph,29mph,29.3in,0.0in,0.0in,Light Rain 00:17:00,12 C,70%,WSW,16mph,30mph,29.3in,0.0in,0.0in,Light Rain 00:17:30,22 C,76%,WSW,17mph,0mph,29.3in,0.0in,0.0in,Light Rain 00:18:00,22 C,87%,WSW,18mph,38mph,29.3in,0.0in,0.0in,Light Rain 00:18:30,12 C,93%,WSW,20mph,35mph,29.3in,0.0in,0.0in,Light Rain 00:19:00,24 C,87%,W,25mph,0mph,29.3in,0.0in,0.0in,Light Rain / Windy 00:19:30,28 C,93%,W,31mph,43mph,29.3in,0.0in,0.0in,Light Rain / Windy
So look at what i mention before,eg if print Temperature it will be in line[1].
with open('new_data.txt') as f:
    for line in f:
        #print(line.strip())
        line = line.split(',')
        print(line[1])
Output:
Temperature 14 C 11 C 23 C 25 C 18 C 10 C 17 C 17 C 23 C 26 C 20 C 21 C 25 C 25 C 27 C 27 C 14 C 13 C 14 C 28 C 10 C 18 C 27 C 15 C 28 C 17 C 23 C 23 C 18 C 14 C 28 C 18 C 29 C 21 C 12 C 22 C 22 C 12 C 24 C 28 C
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 713 Apr-02-2024, 12:36 PM
Last Post: Raysz
  pyspark creating temp files in /tmp folder aliyesami 1 5,311 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,532 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  How to save Matplot chart to temp file? Morkus 2 4,685 Jun-12-2021, 10:52 AM
Last Post: Morkus
  Get system info from PI (cpu load and temp) korenron 2 2,187 Aug-04-2019, 08:45 AM
Last Post: korenron
  Temp folder creation ste1605 7 5,525 Oct-03-2018, 10:39 AM
Last Post: buran
  If/ Or if/ temp controlled fan. clueless 5 4,161 Dec-25-2017, 03:21 AM
Last Post: DeaD_EyE
  Problem with remove Temp Files karlo_ds 1 3,227 Oct-26-2017, 11:42 PM
Last Post: wavic
  How to create a value system with a temp/humidity sensor? Tacoon 2 3,541 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