plot still appearing even if number not valid fixed
This commit is contained in:
parent
dc3672c56b
commit
930d91cfa9
|
@ -1,36 +1,39 @@
|
||||||
import math
|
|
||||||
from secrets import choice
|
from secrets import choice
|
||||||
|
from tracemalloc import stop
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import struct
|
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
|
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
|
||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
tab = np.zeros([1,9])
|
def function():
|
||||||
|
tab = np.zeros([1,9])
|
||||||
|
|
||||||
#def tab_choix():
|
#def tab_choix():
|
||||||
while True:
|
while True:
|
||||||
choice = input("Choisis un fichier csv de 1 à 1862: \n")
|
choice = input("Choisis un fichier csv de 1 à 1862: \n")
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
if float(choice) in range(1, 1863):
|
||||||
|
rawdata = '../RawDataFiles/RawData' + choice + '.csv'
|
||||||
|
with open(rawdata, newline='') as csvfile:
|
||||||
|
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
|
||||||
|
for row in reader:
|
||||||
|
t = np.zeros([1,9])
|
||||||
|
t[0] = row
|
||||||
|
tab = np.append(tab ,t , axis = 0)
|
||||||
|
break
|
||||||
|
|
||||||
|
elif choice > '1862' or choice < '1':
|
||||||
|
print("{} n'est pas un nombre valide.\n".format(choice))
|
||||||
|
exit()
|
||||||
|
|
||||||
if float(choice) in range(1, 1863):
|
x = tab[:,0]
|
||||||
rawdata = '../RawDataFiles/RawData' + choice + '.csv'
|
y = tab[:,1]
|
||||||
with open(rawdata, newline='') as csvfile:
|
print(tab)
|
||||||
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
|
return x , y
|
||||||
for row in reader:
|
|
||||||
t = np.zeros([1,9])
|
|
||||||
t[0] = row
|
|
||||||
tab = np.append(tab ,t , axis = 0)
|
|
||||||
break
|
|
||||||
|
|
||||||
elif choice > '1862' or choice < '1':
|
|
||||||
print("{} n'est pas un nombre valide.".format(choice))
|
|
||||||
break
|
|
||||||
|
|
||||||
x = tab[:,0]
|
|
||||||
y = tab[:,1]
|
|
||||||
|
|
||||||
#Fonction d'affichage du graphique
|
#Fonction d'affichage du graphique
|
||||||
def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "Tension"):
|
def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "Tension"):
|
||||||
|
@ -41,7 +44,10 @@ def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "T
|
||||||
plt.show()
|
plt.show()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
print(tab)
|
|
||||||
#print(x)
|
#print(x)
|
||||||
#print("y = " + str(y))
|
#print("y = " + str(y))
|
||||||
printFig(x,y)
|
def final():
|
||||||
|
x, y = function()
|
||||||
|
printFig(x,y)
|
||||||
|
|
||||||
|
final()
|
Loading…
Reference in a new issue