Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """ Antonio Villanueva Segura
- Load external txt file, process it
- and create a filtered pos. list
- """
- class lista ():
- liste =[] #uploaded string file
- def __init__(self,filename):
- self.openFile(filename)
- def listRange(self,liste,first, last):
- """Show a range of data from the list """
- for listLine in self.liste: #Loop over liste
- print ( listLine[first],listLine[last] )
- def creeListe(self,line):
- """ Create and filter a list from a string line """
- tmp='' #New filtered line
- last='' #last character
- """Filter process line """
- for c in line:
- if c.isprintable() :
- tmp+=c
- elif last != c:
- tmp+='\t'
- last=c
- return tmp.split ('\t')
- def openFile (self,filename):
- """ load File to dataFile """
- with open(filename) as file:
- for line in file:
- if (line.strip()):#Not empty
- self.liste.append(self.creeListe(line))
- def run (self):
- """ loop or main entry"""
- self.listRange (self.liste,1,2)
- if __name__ == "__main__":
- l=lista("configMqtt.txt")
- l.run()
- #Example configMqtt.txt
- """
- ACS-Report-LED 2 01D48089 70b3d56371d48089 Report d’état lumineux
- ACS-Report-LED 2 01D480E3 70b3d56371d480e3 Report d’état lumineux
- ACS-Report-Note 6 0188844F 70b3d5637188844f
- ACS-Switch 3 01D431B6 70b3d56371d431b6
- ACS-Switch-BUZZ 5 01D4B67A 70b3d56371d4b67a
- ACS-Switch-PIR 4 01D3E040 70b3d56371d3e040 Détecteur d’arrivée de véhicule
- ACS-Switch-TOF 1 01D43712 70b3d56371d43712 Capteur à la place
- ACS-Switch-TOF 1 01D43F44 70b3d56371d43f44 Capteur à la place
- INS-Blueread 7 01D43153 70b3d56371d43153
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement