Ajout de la constante de bmi max sur le graphe et basculement sur le fichier de données data.csv

This commit is contained in:
Guyot 2020-05-08 10:10:33 +02:00
parent b715e3d8e8
commit eced3de90c
4 changed files with 51 additions and 4 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
data_perso.csv

View File

@ -13,5 +13,6 @@ set x2tics format "%Y"
set xtics nomirror set xtics nomirror
set xrange [*:*] set xrange [*:*]
set datafile separator '|' set datafile separator '|'
plot 'data2.csv' using 3:1 pt 'X' title '' f(x) = 86.41099999999999
plot 'data.csv' using 3:1 pt '.' title '', f(x) lt 7 title 'bmi'
#pause -1 'En attente de RETURN' #pause -1 'En attente de RETURN'

29
data.csv Normal file
View File

@ -0,0 +1,29 @@
70|WEIGHT|2015-10-03 03:30:13|true|| amusant|
72|WEIGHT|2015-10-04 09:35:57|true||null|
72|WEIGHT|2015-10-05 09:50:00|true||null|
73|WEIGHT|2015-10-07 08:47:46|true||null|
72|WEIGHT|2015-10-08 09:07:48|true||null|
72|WEIGHT|2015-10-12 09:41:31|true||null|
78|WEIGHT|2016-01-20 07:57:11|true||null|
80|WEIGHT|2016-03-05 09:25:58|true||null|
76|WEIGHT|2016-05-30 07:34:45|true||null|
80|WEIGHT|2016-06-19 11:36:48|true||À 11h|
84|WEIGHT|2016-07-01 07:51:22|true||null|
87|WEIGHT|2016-07-02 09:25:54|true||Avant vac été|
93|WEIGHT|2016-07-31 08:06:30|true||Après vac été|
94|WEIGHT|2016-08-01 09:06:22|true||Après raclette|
95|WEIGHT|2016-08-09 08:32:34|true||null|
84|WEIGHT|2017-03-04 08:25:23|true||null|
85|WEIGHT|2017-05-27 08:44:10|true||null|
82|WEIGHT|2017-09-07 07:12:46|true||null|
86|WEIGHT|2017-11-10 07:20:46|true||null|
81|WEIGHT|2018-01-06 09:01:48|true||null|
85|WEIGHT|2018-02-24 09:11:08|true||null|
79|WEIGHT|2019-01-08 07:37:27|true||null|
75|WEIGHT|2019-01-31 08:39:33|true||null|
78|WEIGHT|2019-03-29 08:27:02|true||null|
82|WEIGHT|2019-09-29 08:19:32|true||null|
84.6|WEIGHT|2020-03-02 12:58:57|true||null|
80.1|WEIGHT|2020-04-13 12:41:11|true||null|
79|WEIGHT|2020-04-14 08:29:45|true||null|
75|WEIGHT|2020-05-08 07:53:28|true||null|
1 70 WEIGHT 2015-10-03 03:30:13 true amusant
2 72 WEIGHT 2015-10-04 09:35:57 true null
3 72 WEIGHT 2015-10-05 09:50:00 true null
4 73 WEIGHT 2015-10-07 08:47:46 true null
5 72 WEIGHT 2015-10-08 09:07:48 true null
6 72 WEIGHT 2015-10-12 09:41:31 true null
7 78 WEIGHT 2016-01-20 07:57:11 true null
8 80 WEIGHT 2016-03-05 09:25:58 true null
9 76 WEIGHT 2016-05-30 07:34:45 true null
10 80 WEIGHT 2016-06-19 11:36:48 true À 11h
11 84 WEIGHT 2016-07-01 07:51:22 true null
12 87 WEIGHT 2016-07-02 09:25:54 true Avant vac été
13 93 WEIGHT 2016-07-31 08:06:30 true Après vac été
14 94 WEIGHT 2016-08-01 09:06:22 true Après raclette
15 95 WEIGHT 2016-08-09 08:32:34 true null
16 84 WEIGHT 2017-03-04 08:25:23 true null
17 85 WEIGHT 2017-05-27 08:44:10 true null
18 82 WEIGHT 2017-09-07 07:12:46 true null
19 86 WEIGHT 2017-11-10 07:20:46 true null
20 81 WEIGHT 2018-01-06 09:01:48 true null
21 85 WEIGHT 2018-02-24 09:11:08 true null
22 79 WEIGHT 2019-01-08 07:37:27 true null
23 75 WEIGHT 2019-01-31 08:39:33 true null
24 78 WEIGHT 2019-03-29 08:27:02 true null
25 82 WEIGHT 2019-09-29 08:19:32 true null
26 84.6 WEIGHT 2020-03-02 12:58:57 true null
27 80.1 WEIGHT 2020-04-13 12:41:11 true null
28 79 WEIGHT 2020-04-14 08:29:45 true null
29 75 WEIGHT 2020-05-08 07:53:28 true null

View File

@ -73,7 +73,7 @@ def save_file_data():
linenum = 0 linenum = 0
for row in contents: for row in contents:
if row.split(' ',1)[0] == 'plot': if row.split(' ',1)[0] == 'plot':
contents.insert(linenum, "plot '"+args.data+"' using 3:1 pt 'X' title ''\n") contents.insert(linenum, "plot '"+args.data+"' using 3:1 pt '.' title '', f(x) lt 7 title 'bmi'\n")
del(contents[linenum+1]) del(contents[linenum+1])
linenum += 1 linenum += 1
f = open("Fonctionnel.txt", "w") f = open("Fonctionnel.txt", "w")
@ -198,11 +198,27 @@ def plot_graph():
#print(stdout) #print(stdout)
def save_size(): def save_size():
print(bmi_weight_max())
""" Store the size """ """ Store the size """
f = open('personal.txt', "w") f = open('personal.txt', "w")
f.write(str(args.size)) f.write(str(args.size))
f.close() f.close()
f = open("Fonctionnel.txt", "r")
contents = f.readlines()
f.close()
linenum = 0
for row in contents:
motif = row.split(' ',2)[0]+' '+row.split(' ',2)[1]
if motif == 'f(x) =':
contents.insert(linenum, "f(x) = "+str(bmi_weight_max())+"\n")
del(contents[linenum+1])
linenum += 1
f = open("Fonctionnel.txt", "w")
contents = "".join(contents)
f.write(contents)
f.close()
def tests_subproc(): def tests_subproc():
""" Test of the subprocess module """ """ Test of the subprocess module """
process = Popen(['cat', 'data2.csv'], stdout=PIPE, stderr=PIPE) process = Popen(['cat', 'data2.csv'], stdout=PIPE, stderr=PIPE)
@ -210,7 +226,7 @@ def tests_subproc():
print(stdout) print(stdout)
def bmi(the_weight): def bmi(the_weight):
""" Return the BMI for a given weight """ """ Return the BMI for a given size """
f = open('personal.txt', "r") f = open('personal.txt', "r")
the_size = float(f.read()) the_size = float(f.read())
f.close() f.close()
@ -237,7 +253,7 @@ texte = _('A script to manage your weight in command line.')
parser.description=texte parser.description=texte
# Creating arguments # Creating arguments
parser.add_argument('-da', '--data', parser.add_argument('-da', '--data',
default='data2.csv', default='data.csv',
help=_('optional : file data') help=_('optional : file data')
) )
parser.add_argument('-s', '--size', parser.add_argument('-s', '--size',