diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85f1441 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data_perso.csv diff --git a/Fonctionnel.txt b/Fonctionnel.txt index dee68f3..c9e2d43 100644 --- a/Fonctionnel.txt +++ b/Fonctionnel.txt @@ -13,5 +13,6 @@ set x2tics format "%Y" set xtics nomirror set xrange [*:*] 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' diff --git a/data.csv b/data.csv new file mode 100644 index 0000000..9ecba59 --- /dev/null +++ b/data.csv @@ -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| diff --git a/weight-cli.py b/weight-cli.py index a002323..289b861 100644 --- a/weight-cli.py +++ b/weight-cli.py @@ -73,7 +73,7 @@ def save_file_data(): linenum = 0 for row in contents: 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]) linenum += 1 f = open("Fonctionnel.txt", "w") @@ -198,11 +198,27 @@ def plot_graph(): #print(stdout) def save_size(): + print(bmi_weight_max()) """ Store the size """ f = open('personal.txt', "w") f.write(str(args.size)) 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(): """ Test of the subprocess module """ process = Popen(['cat', 'data2.csv'], stdout=PIPE, stderr=PIPE) @@ -210,7 +226,7 @@ def tests_subproc(): print(stdout) def bmi(the_weight): - """ Return the BMI for a given weight """ + """ Return the BMI for a given size """ f = open('personal.txt', "r") the_size = float(f.read()) f.close() @@ -237,7 +253,7 @@ texte = _('A script to manage your weight in command line.') parser.description=texte # Creating arguments parser.add_argument('-da', '--data', - default='data2.csv', + default='data.csv', help=_('optional : file data') ) parser.add_argument('-s', '--size',