Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Truth has always been found to promote the best interests of mankind... -- Percy Bysshe Shelley


devel / comp.lang.python / RE: Trying to read from a text file to generate a graph

SubjectAuthor
o RE: Trying to read from a text file to generate a graphSteve

1
RE: Trying to read from a text file to generate a graph

<mailman.276.1627487908.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14328&group=comp.lang.python#14328

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Groni...@SGA.Ninja (Steve)
Newsgroups: comp.lang.python
Subject: RE: Trying to read from a text file to generate a graph
Date: Wed, 28 Jul 2021 11:58:21 -0400
Lines: 149
Message-ID: <mailman.276.1627487908.4164.python-list@python.org>
References: <014701d7837d$96643820$c32ca860$@SGA.Ninja>
<YQEUbsro2JdIs1kD@cskk.homeip.net>
<018f01d783c9$648fa680$2daef380$@SGA.Ninja>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de pJB8PUKIqs0TLR4b0qQMUA9gf335LF0OKYaAdPA5bq9A==
Return-Path: <Gronicus@SGA.Ninja>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=sga.ninja header.i=@sga.ninja header.b=eqY0Xbbb;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.027
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'jul': 0.04; 'variable':
0.05; 'loop': 0.07; 'sensor': 0.07; 'fails': 0.09; 'graph': 0.09;
'numpy': 0.09; 'populate': 0.09; 'subject:Trying': 0.09;
'url:stable': 0.09; 'import': 0.14; '144,': 0.16; 'complete.':
0.16; 'follows': 0.16; 'from:addr:gronicus': 0.16;
'from:addr:sga.ninja': 0.16; 'from:name:steve': 0.16; 'generates':
0.16; 'graphs': 0.16; 'labels': 0.16; 'message-id:@SGA.Ninja':
0.16; 'program:': 0.16; 'received:floathosting.com': 0.16;
'received:mars.floathosting.com': 0.16; 'sensors,': 0.16;
'width,': 0.16; 'wrote:': 0.16; 'values': 0.16; 'code.': 0.19;
'uses': 0.19; 'generated': 0.20; 'subject:file': 0.23; 'to:addr
:python-list': 0.23; 'lines': 0.24; 'run': 0.24; 'code': 0.24;
'section': 0.26; '111': 0.27; 'zip': 0.27; 'creating': 0.27;
'text': 0.29; 'there': 0.31; 'code,': 0.31; 'but': 0.31;
'program,': 0.31; '165': 0.32; '211': 0.32; '23,': 0.32;
'attaching': 0.32; 'good.': 0.32; 'half': 0.32; 'python-list':
0.32; 'skip:= 50': 0.32; 'program': 0.33; 'using': 0.33; 'header
:In-Reply-To:1': 0.33; 'subject:from': 0.35; 'following': 0.35;
'22,': 0.35; 'bar': 0.35; 'file': 0.38; 'though': 0.38; 'going':
0.38; 'to:2**1': 0.38; 'use': 0.38; 'does': 0.38; 'main': 0.40;
'test': 0.40; 'skip:e 10': 0.60; 'hope': 0.61; 'here': 0.62;
'choose': 0.62; 'website.': 0.62; 'url-ip:172.67/16': 0.64;
'pass': 0.64; 'url:index': 0.64; 'only,': 0.65; 'number:': 0.66;
'look': 0.66; 'skip:o 20': 0.67; 'site': 0.69; 'subject:read':
0.69; 'through.': 0.69; 'shows': 0.70; 'selecting': 0.77; 'url-
ip:104.26/16': 0.79; '2021': 0.84; '132,': 0.84; '277': 0.84;
'bars': 0.84; 'explain.': 0.84; 'forgot': 0.84; 'minor': 0.84;
'sensors': 0.84; 'struggle': 0.84; 'demo': 0.91; 'url-
ip:104.26.0/24': 0.91; 'url-ip:104.26.1/24': 0.91; 'url-
ip:172.67.74/24': 0.91; 'width': 0.91
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sga.ninja;
s=default;
h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:
Date:Subject:In-Reply-To:References:To:From:Sender:Reply-To:Cc:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
List-Post:List-Owner:List-Archive;
bh=sCvdhEsrAgymiMeuYv1YGC+zK2WRN4vLtLRErFtRK14=; b=eqY0XbbbBp/HbDGFZvgempXgAS
Ihyo7n6RjlkGnsc66R4GcVRy4F7KTOTe08ZDTga9cNAQTHSfFFKv+f05ZFW3L+93GXusRteM9sMs5
D9CgI+FLJ12MqP0Uaw9R+5JzTjdwJ+ayM4prN/QFFT59Vkw4T4xXtLoUxklrOiJKP2ebqHLCj5HTA
V/Xs11NFbVpZzDOV6A5sIhBiGEsJZQbG2KeAoIFL2BbECpzp56i862eRXW9ib598S4W/tr3AXma3B
Rxq96GIHPna71l+8s2cRyE/ilELSAfphfvM8PzATp4IMHKz4HlEJ5r9SOf6eHHEArHbAiEts593GF
XImgLEuA==;
In-Reply-To: <YQEUbsro2JdIs1kD@cskk.homeip.net>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQIP6HBidjgv9u8kRMmSj6PYtsFCfAI4KWhYqtX96XA=
Content-Language: en-us
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - mars.floathosting.com
X-AntiAbuse: Original Domain - python.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - SGA.Ninja
X-Get-Message-Sender-Via: mars.floathosting.com: authenticated_id:
gronicus@sga.ninja
X-Authenticated-Sender: mars.floathosting.com: gronicus@sga.ninja
X-Source:
X-Source-Args:
X-Source-Dir:
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <018f01d783c9$648fa680$2daef380$@SGA.Ninja>
X-Mailman-Original-References: <014701d7837d$96643820$c32ca860$@SGA.Ninja>
<YQEUbsro2JdIs1kD@cskk.homeip.net>
 by: Steve - Wed, 28 Jul 2021 15:58 UTC

I forgot about the no-file rule...

On 28Jul2021 02:55, Steve <Gronicus@SGA.Ninja> wrote:
>I am going though a struggle with this and just don't see where it fails.
>I am using the Dual Bar Graph.py program from
https://matplotlib.org/stable/gallery/index.html website.
>The file from the web site works so that shows that all my installations
are complete.
>
>My program, LibreGraphics 05.py program runs but the graph is all smutched
up. I am pulling data from the EXCEL-FILE.txt into the program, selecting
three values for each line and creating three variables formatted as is
shown in the original demo file.
>
>When you run the program, choose 112 when prompted. You will see the values
of the variables I want to pass to the graph section of the code. If the
values are hardcoded, the graphs look good. When the variables generated by
my section of the code, it does not.
>
>I am not sure what more to explain.
>Please help me....
>Steve
>
>I am attaching a zip file. I hope it gets through.

Alas, the python-list is text only, and attachments are discarded.

Here is my code for the main program:
=====================================================================

#https://matplotlib.org/stable/gallery/index.html

import matplotlib.pyplot as plt
import numpy as np

## In this first half of the program, I am reading lines of data from
## a file and reformatting them to create comms separated values into
## three variables.

Sensors = ""
TestStrips = ""
SampleNumber = ""

x = 1
SensorNumber = input("Enter senaor number: ")
with open("_EXCEL-FILE.txt" , 'r') as infile:
for lineEQN in infile: # loop to find each line in the file for that
dose
if (lineEQN[0:1]== "."):
SN = lineEQN[44:48].strip()
if (SensorNumber == SN):
SN = x
sn = "'" + str(SN) + "', "
SampleNumber = SampleNumber + sn

sv = lineEQN[25:29].strip()
sv = sv + ", "
Sensors = Sensors + sv

tv = lineEQN[32:37].strip()
tv = tv + ", "
TestStrips = TestStrips + tv

x += 1

SnLen = len(SampleNumber) -2
SampleNumber = SampleNumber[0:SnLen]
labels = "[" + SampleNumber + "]"
print("labels = " + labels)

SenLen = len(Sensors) -2
Sensors = Sensors[0:SenLen]
Sensors = "[" + Sensors + "]"
print("Sensors = " + Sensors)

TsLen = len(TestStrips) -2
TestStrips = TestStrips[0:TsLen]
TestStrips = "[" + TestStrips + "]"
print("TestStrips = " + TestStrips)

labels = SampleNumber

## =============================================================

## In this second half of the program, I want to use the three
## variables ## to populate a fraph.

## There are problems with this technique.

## =============================================================
## With the following 6 lines of code commented-out, the graphing
## program uses the variables from the first half of the program
## and the graph fails

## =============================================================

## Uncommented, the following works by overwriting the variables
## from the previous code and generates a proper graph.

#label = ['1', '2', '3', '4', '5']
#Sensor = [150, 132, 182, 75, 117]
#TestStrip = [211, 144, 219, 99, 142]

#labels = label
#Sensors = Sensor
#TestStrips = TestStrip

## ===========================================================

## The follows is the original cose from the sample program
## with minor variable names and label changes.

x = np.arange(len(labels)) # the label locations
width = 0.35 # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, Sensors, width, label='Sensors')
rects2 = ax.bar(x + width/2, TestStrips, width, label='TestStrips')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Glucose Readings')
ax.set_title('Sensors VS Test Strip')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)

fig.tight_layout()

plt.show()

===========================================================
And here is a sample of the data file:

..Thu Jul 22, 2021 20:47 250 277 27 111 2

..Fri Jul 23, 2021 00:05 188 194 6 111 3
..Fri Jul 23, 2021 09:08 142 166 24 111 3
..Fri Jul 23, 2021 12:58 138 165 27 111 3
..Fri Jul 23, 2021 22:32 356 391 35 111 3

..Sat Jul 24, 2021 09:44 150 211 61 112 4
..Sat Jul 24, 2021 13:24 132 144 12 112 4
..Sat Jul 24, 2021 16:40 182 213 31 112 4
..Sat Jul 24, 2021 19:52 75 99 24 112 4
..Sat Jul 24, 2021 23:19 117 142 25 112 4

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor