In [1]:
# import de la librairie pandas
import pandas as pd

In [2]:
# ouverture du fichier csv
data = pd.read_csv('donnees.csv')

In [3]:
# affichage de la table des données lue
print(data)


   Champ1  Champ2
0     0.0     0.1
1     0.1     0.3

In [4]:
# opérations sur le fichier (ex: ajout d'une colonne 'Total' et d'une colonne 'Command')
data['Total'] = data['Champ1'] + data['Champ2']
data['Command'] = data.apply(lambda x:  'METTRE LE CAP A '+str(x.Total), axis=1)

In [5]:
# affichage de la nouvelle table résultante
print(data)


   Champ1  Champ2  Total              Command
0     0.0     0.1    0.1  METTRE LE CAP A 0.1
1     0.1     0.3    0.4  METTRE LE CAP A 0.4

In [6]:
# extraction de la colonne 'Command' seule et ecriture dans un fichier output
data['Command'].to_string('output.txt')

In [ ]:


In [7]:
# ouverture du fichier csv
!cat output.txt


0    METTRE LE CAP A 0.1
1    METTRE LE CAP A 0.4