from pickletools import long1 from secrets import choice from turtle import goto import numpy as np import matplotlib.pyplot as plt import csv #"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT" #! /usr/bin/env python3 # -*- coding: UTF-8 -*- # x = tab[:,0] # y = tab[:,1] # print(tab) # return x , y #fonction choix du capteur à afficher : #bool true si capteur veux être utiliser sinon false (tableau) def function(): while True: print("\n") choice = input("(1) Choisis un fichier csv de 1 à 1862: ") print("\n") if float(choice) in range(1, 1863): rawdata = '../RawDataFiles/RawData' + choice + '.csv' #Définit le fichier à ouvrir choice2 = input("(2) Choisir un capteur à afficher en particulier dans le tableau? oui/non \n") print("\n") if choice2 == "oui": while True: ccapteur = int(input("(3) Choisis parmis les capteurs (1, 2, 3, 4, 5, 6, 7, 8): ")) print("\n") if ccapteur in (1,2,3,4,5,6,7,8): #Affiche le capteur sélectionner with open(rawdata, newline='') as csvfile: reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC) x = [row for row in reader] int_x = np.array(x, int) column_index = [ccapteur + 1] for col in column_index: column_values = np.empty(0) for array in range(len(int_x)): column_values = np.append(column_values, np.array(int_x[array][col-1])) plt.plot(column_values) plt.show() exit() elif ccapteur != (1,2,3,4,5,6,7,8): print("{} n'est pas un nombre valide.\n".format(int(ccapteur))) elif choice2 == "non": #Ouvre le csv file et affiche tout les capteurs with open(rawdata, newline='') as csvfile: reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC) x = [row for row in reader] int_x = np.array(x, int) column_index = [2,3,4,5,6,7,8,9] for col in column_index: column_values = np.empty(0) for array in range(len(int_x)): column_values = np.append(column_values, np.array(int_x[array][col-1])) plt.plot(column_values) plt.show() break elif choice > '1862' or choice < '1': print("{} n'est pas un nombre valide.\n".format(choice)) #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(x) #print("y = " + str(y)) def final(): function() #printFig() final()