diff --git a/Py-Script/courbe.py b/Py-Script/courbe.py index cbdc604..b8ec0fa 100644 --- a/Py-Script/courbe.py +++ b/Py-Script/courbe.py @@ -1,5 +1,5 @@ -from asyncore import read import math +from secrets import choice import numpy as np import matplotlib.pyplot as plt import struct @@ -9,18 +9,39 @@ import csv #! /usr/bin/env python3 # -*- coding: UTF-8 -*- -def tab(): - with open('../RawDataFiles/RawData1.csv', 'r') as f: - data = csv.reader(f, quoting = csv.QUOTE_MINIMAL) - data2 = [data2 for data2 in data] - data_array = np.asarray(data2) - print(data_array[:,5]) +tab = np.zeros([1,9]) -def graph(): - plt.xlabel('Temps') - plt.ylabel('Tension') - plt.title("Données tableau 1") - plt.plot(x, y, color = 'r') - plt.show() #Affichage du plot +#def tab_choix(): +while True: + choice = input("Choisis un fichier csv de 1 à 1862: \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.".format(choice)) + break -tab() \ No newline at end of file +x = tab[:,0] +y = tab[:,1] + +#Fonction d'affichage du graphique +def printFig(axe_x , axe_y , title = "new plot" , xlabel = "Temps" , ylabel = "Tension"): + plt.plot(axe_x , axe_y) + plt.xlabel(xlabel) + plt.ylabel(ylabel) + plt.title(title) + plt.show() + return 0 + +print(tab) +#print(x) +#print("y = " + str(y)) +printFig(x,y) \ No newline at end of file