Jul-11-2019, 11:35 AM
I often need to loop through a list of logs and parse them.
I like to use, for instance, an ip and hostname as designations for files creation. Its just easy to look at the file and know what / who it belows too.
My question is .. is there a better way to split things apart ?
Sample data
Existing Code
Thnks in advance
Sum
I like to use, for instance, an ip and hostname as designations for files creation. Its just easy to look at the file and know what / who it belows too.
My question is .. is there a better way to split things apart ?
Sample data
Quote:10.10.10.10_hostname1.log
10.10.10.11_hostname2.log
10.10.10.12_hostname3.log
Existing Code
def main(): for file in glob.glob("*.log"): file, fext = os.path.splitext(file) ip, hnam = file.split("_") print(file) print(ip) print(hnam) main()Output. But his output is just check results vars will be used eleswhere in the developing program.
Quote:10.10.10.10_house
10.10.10.10
house
10.10.10.11_house2
10.10.10.11
house2
10.10.10.11_house3
10.10.10.11
house3
Thnks in advance
Sum