From 548ff3c52201ac8134c51e4540091d88a0175484 Mon Sep 17 00:00:00 2001 From: Guyot Date: Tue, 21 Apr 2020 23:41:21 +0200 Subject: [PATCH] =?UTF-8?q?Le=20changement=20du=20fichier=20de=20donn?= =?UTF-8?q?=C3=A9=20pour=20le=20trac=C3=A9=20Gnuplot=20est=20fonctionnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Fonctionnel.txt | 2 +- Fonctionnel_back.txt | 16 ++++++++++++++++ data2.csv | 6 ++++-- data3.csv | 21 +++++++++++++++------ remove.txt | 2 +- weight-cli.py | 20 +++++++++++++++++++- 6 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 Fonctionnel_back.txt diff --git a/Fonctionnel.txt b/Fonctionnel.txt index 391cb48..e56150b 100644 --- a/Fonctionnel.txt +++ b/Fonctionnel.txt @@ -12,5 +12,5 @@ set x2tics format "%Y" set xtics nomirror set datafile separator '|' -plot 'data.csv' using 3:1 pt '.' title '' +plot 'data2.csv' using 3:1 pt '.' title '' #pause -1 'En attente de RETURN' diff --git a/Fonctionnel_back.txt b/Fonctionnel_back.txt new file mode 100644 index 0000000..391cb48 --- /dev/null +++ b/Fonctionnel_back.txt @@ -0,0 +1,16 @@ +#set term dumb 50 20 +set term dumb #nofeed +set title 'Courbe de poids' +set timefmt "%Y-%m-%d %H:%M:%S" +set xdata time +set xmtics +set xlabel "Mois" +#set xtics format "%Y-%d-%m" +set x2data time +set x2label "Années" +set x2tics format "%Y" +set xtics nomirror + +set datafile separator '|' +plot 'data.csv' using 3:1 pt '.' title '' +#pause -1 'En attente de RETURN' diff --git a/data2.csv b/data2.csv index 595bbe4..33476a9 100644 --- a/data2.csv +++ b/data2.csv @@ -1,3 +1,5 @@ -6|WEIGHT|2020-04-15 11:16:58|True| |6e test| -7|WEIGHT|2020-04-15 11:18:06|True| |7e test| +6|WEIGHT|2020-02-15 11:16:58|True| |6e test| +7|WEIGHT|2020-03-15 11:18:06|True| |7e test| 13.0|WEIGHT|2020-04-20 17:39:31|true||8e test| +15.0|WEIGHT|2020-06-21 22:34:56|true|| | +16.0|WEIGHT|2020-08-21 22:35:00|true|| | diff --git a/data3.csv b/data3.csv index 31b7a81..7684995 100644 --- a/data3.csv +++ b/data3.csv @@ -1,6 +1,15 @@ -6|WEIGHT|2020-04-15 11:16:58 -7|WEIGHT|2020-04-15 11:18:06 -8|WEIGHT|2020-04-15 11:26:06 -9|WEIGHT|2020-04-15 11:27:45 -10|WEIGHT|2020-04-15 11:39:12 -10.1|WEIGHT|2020-04-15 15:22:22 +#set term dumb 50 20 +set term dumb #nofeed +set title 'Courbe de poids' +set timefmt "%Y-%m-%d %H:%M:%S" +set xdata time +set xmtics +set xlabel "Mois" +#set xtics format "%Y-%d-%m" +set x2data time +set x2label "Années" +set x2tics format "%Y" +set xtics nomirror + +set datafile separator '|' +plot 'data3.csv' using 3:1 pt '.' title ''#pause -1 'En attente de RETURN' diff --git a/remove.txt b/remove.txt index 4846dea..4c8d1fb 100644 --- a/remove.txt +++ b/remove.txt @@ -1 +1 @@ -2 13.0|WEIGHT|2020-04-20 17:39:31|true||8e test| +3 14.0|WEIGHT|2020-04-21 22:34:40|true|| | diff --git a/weight-cli.py b/weight-cli.py index f949821..6ac1dbd 100644 --- a/weight-cli.py +++ b/weight-cli.py @@ -50,6 +50,22 @@ Une mesure est caractérisée par : - autre """ +def save_file_data(): + f = open("Fonctionnel.txt", "r") + contents = f.readlines() + f.close() + linenum = 0 + for row in contents: + if row.split(' ',1)[0] == 'plot': + contents.insert(linenum, "plot '"+args.data+"' using 3:1 pt '.' title ''\n") + del(contents[linenum+1]) + linenum += 1 + f = open("Fonctionnel.txt", "w") + contents = "".join(contents) + f.write(contents) + f.close() + + def save_mesure(): """ Affichage et enregistrement d'une mesure """ print("Votre mesure a été enregistrée : ") @@ -113,7 +129,7 @@ def undo_remove(): g = open('remove.txt', 'r') store_temp = g.readline().split(' ',1) g.close() - # insert the line item from list, by line number, starts from 0 + # insert the line item from list, by its line number contents.insert(int(store_temp[0]), store_temp[1]) f = open(args.data, "w") @@ -208,6 +224,8 @@ parser.add_argument('-v', '--version', # Récupération des arguments args = parser.parse_args() # Lancement des actions +if args.data != -1: + save_file_data() if args.weight != -1: save_mesure() if args.read: