From b92cb19bfcff5286f4aefac8464d39639262703e Mon Sep 17 00:00:00 2001 From: pvalarcher Date: Fri, 18 Nov 2022 09:17:43 +0100 Subject: [PATCH] csv --- python/5/cle.txt | 1 + python/5/codage.py | 54 ++++++++++++++++++++++++++++++++++++++++++++ python/5/code.txt | 1 + python/5/esr.py | 36 +++++++++++++++++++++++++++++ python/5/exoNote.py | 17 ++++++++++++++ python/5/message.txt | 5 ++-- 6 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 python/5/cle.txt create mode 100755 python/5/codage.py create mode 100644 python/5/code.txt create mode 100755 python/5/esr.py create mode 100755 python/5/exoNote.py diff --git a/python/5/cle.txt b/python/5/cle.txt new file mode 100644 index 0000000..1bfefa1 --- /dev/null +++ b/python/5/cle.txt @@ -0,0 +1 @@ +wo4Fo\F( u \ No newline at end of file diff --git a/python/5/codage.py b/python/5/codage.py new file mode 100755 index 0000000..4a67cef --- /dev/null +++ b/python/5/codage.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import random + +file_message = open("message.txt", "r") +file_cle = open("cle.txt", "w") +file_code = open("code.txt", "w") + +## Supposons que message.txt contienne +## Il +## fait +## beau! + +lignes = file_message.readlines() + +for message in lignes: + + longM = len(message) + + cle = "" + + for i in range(longM): + j = random.randint(0,127) + l = chr(j) + cle = cle + l + + file_cle.write(cle) + + + messagecode = "" + + for i in range (longM): + ccode = chr( (ord(message[i]) + ord(cle[i])) % 127) + messagecode = messagecode + ccode + + file_code.write(messagecode) + + + + + + + + + + + + + + + +file_message.close() +file_cle.close() +file_code.close() + \ No newline at end of file diff --git a/python/5/code.txt b/python/5/code.txt new file mode 100644 index 0000000..3e8c36d --- /dev/null +++ b/python/5/code.txt @@ -0,0 +1 @@ +Jdy(Yf)jk8 \ No newline at end of file diff --git a/python/5/esr.py b/python/5/esr.py new file mode 100755 index 0000000..8cf09ef --- /dev/null +++ b/python/5/esr.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + + +# Polarité;Action;Fait;Valeur;Ordre +f = open("fr-esr-referentiel_de_transformation_numerique_esr.csv","r") + +lignes = f.readlines() + +chiffres = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] + +### Recherche de l'indice de la colonne 'Ordre' +entete = lignes[0].split(';') +print (entete) +# entete = ['Polarité', 'Action', 'Fait', 'Valeur', 'Ordre'] +indice = 0 +while (entete[indice] != 'Ordre') and (entete[indice] != 'Ordre\n'): + indice = indice + 1 +print("indice : ", indice) + +ordre_min_actuel = 1000000 +num_ligne = 0 +i = 0 +for ligne in lignes: + l = ligne.split(';') + # l[indice][0] c'est le premier caractère + # l[indice] == '89'== ['8', '9'] + if l[indice][0] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: + + if int(l[indice]) < ordre_min_actuel: + + ordre_min_actuel = int(l[indice]) + num_ligne = i + i = i + 1 + + +print(lignes[num_ligne]) \ No newline at end of file diff --git a/python/5/exoNote.py b/python/5/exoNote.py new file mode 100755 index 0000000..9c35b50 --- /dev/null +++ b/python/5/exoNote.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +nomFic = input("Entrer un nom de fichier : ") + +f = open(nomFic, "r") + +lignes = f.readlines() + +c = 0 + +for ligne in lignes: + for i in range(len(ligne)): + if ligne[i] == 'a': + c = c + 1 + +f.close() +print("il y a ", c, " 'a' dans le ficher!") diff --git a/python/5/message.txt b/python/5/message.txt index 3df932d..524ee1e 100644 --- a/python/5/message.txt +++ b/python/5/message.txt @@ -1,2 +1,3 @@ -La pluie est bleue! -Q'en pensez vous? \ No newline at end of file +Il +fait +beau! \ No newline at end of file