long story short im looking at the 4th field on a file which usually contains either one of the 2 below
a) abcd1234[1234]
b) abcd1234:
my question is is there a way to do the .split function with multiple varbs so instead of .split('[')[1] whats the correct way to do multiple.
Ive tried a couple of things and searched around but no luck
variable i question is processcorrected i want it to be either [ or :
Code:
#!/usr/bin/python
file = open('/var/log/messages')
for line in file:
word = line.split(' ')
date = word[0]
server = word[3]
process = word[4]
processcorrected = process.split('[')[1]
print "time is %s, server is %s" % (date, server)