1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#! /usr/bin/env python
#coding=utf-8
pathOfTheFile = "fichierEntree.txt"
infosFound = []
with open(pathOfTheFile, mode = 'r') as fileToAnalyse:
for oneLine in fileToAnalyse:
oneLine = oneLine.strip()
if oneLine.startswith('macro'):
id = oneLine\
.replace('macro', '')\
.replace('(', '')\
.replace(')', '')\
.replace('{', '')
id = id.strip()
elif oneLine.startswith('pin_ert'):
val = oneLine\
.replace('pin_ert', '')\
.replace(':', '')\
.replace('"', '')\
.replace(';', '')
val = val.strip()
infosFound.append(id + '_' + val)
with open('sortie.txt', mode = 'w') as answer:
answer.write('\n'.join(infosFound)) |
Partager