Python Forum
[Solved] Plotting data from txt file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Plotting data from txt file
#2
I've now changed the composition of the values so that I have everything in a list. Now what I'd have to do is stack every 8th value into a column somehow, if that's possible, or create a loop to calculate the averages of every 8th value etc. The output is now this:

[['#0'], ['0.4000'], ['0.1500'], ['1.5187'], ['Fixed'], ['Fixed'], ['0.0473'], ['76.2093'], ['8.8510'], ['14.9398'], ['1.3789'], ['0.9853'], ['0.5720'], ['40.4648'], ['0.0551'], ['#1'], ['0.4000'], ['0.1500'], ['1.5094'], ['Fixed'], ['Fixed'], ['0.0450'], ['74.3954'], ['9.9777'], ['15.6269'], ['1.3704'], ['0.9724'], ['0.5760'], ['40.5128'], ['0.0545'], ['#2'], ['0.4000'], ['0.1500'], ['1.5491'], ['Fixed'], ['Fixed'], ['0.0468'], ['74.7040'], ... ['Fixed'], ['Fixed'], ['0.0536'], ['77.1376'], ['8.7556'], ['14.1069'], ['1.2754'], ['0.9602'], ['0.4889'], ['40.5042'], ['0.0548']]
(with this code):

my_file = open(out, "r")
content = my_file.read()

content_list = content.split()
my_file.close()

myList = content_list
myList = [i.split('\n') for i in myList] 
del myList[0:10]
print(myList)
So now I'd have to calculate averages of every 8th value, as well as plot them. I suppose it's easier this way: is there a method to stack the values into columns somehow, is the only option loop over the values? Any help is greatly appreciated!
Reply


Messages In This Thread
[Solved] Plotting data from txt file - by Laplace12 - Jul-04-2021, 02:14 PM
RE: Plotting data from txt file - by Laplace12 - Jul-06-2021, 07:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] Correct way to convert file from cp-1252 to utf-8? Winfried 8 1,038 Feb-29-2024, 12:30 AM
Last Post: Winfried
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,194 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  [Solved by deanhystad] Create a zip file using zipfile library DZ_Galaxy 2 1,200 Aug-17-2022, 04:57 PM
Last Post: DZ_Galaxy
  [SOLVED] Concat data from dictionary? Winfried 4 1,751 Mar-30-2022, 02:55 PM
Last Post: Winfried
  Updating a config file [solved] ebolisa 8 2,643 Nov-04-2021, 10:20 AM
Last Post: Gribouillis
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,533 Oct-21-2021, 03:29 AM
Last Post: buran
  [SOLVED] Read text file from some point till EOF? Winfried 1 1,988 Oct-10-2021, 10:29 PM
Last Post: Winfried
  [SOLVED] Input parameter: Single file or glob? Winfried 0 1,602 Sep-10-2021, 11:54 AM
Last Post: Winfried
Thumbs Up [SOLVED] Find last occurence of pattern in text file? Winfried 4 4,461 Aug-13-2021, 08:21 PM
Last Post: Winfried
Thumbs Up Parsing a YAML file without changing the string content..?, Flask - solved. SpongeB0B 2 2,306 Aug-05-2021, 08:02 AM
Last Post: SpongeB0B

Forum Jump:

User Panel Messages

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