python - Creating list throws error -
i learning python , trying out parse , create list part of logs.
09 jan 2011 11:24:02 utc,09 jan 2011 11:24:02 utc,5,,,,32871237,,,finance [trievent] imported [jan:9|aol deal|restricted new||low_val_pass|low_val_pass|low| transid=32871237 region=us in=347 out=2308 significance=error category=finance outcome=/failure art=1382919579 cat=main deviceresponse=200 act=observed uri=/all trans/fiance system suser=u98932 dst=10.1.1.1 filetype=text/javascript;charset=utf-8 request=https://www.dsakdjasdj.org/graphs/concepts/expect_and_var#focus=problem&mode=learn
heres code create new list use create dictionary.
path = 'd:/\testfie' new_list = ['transid', 'region', 'in', 'out'] new_dict = {} val_list = [] open( path, 'rb') f: reader = csv.reader(f,delimiter=',') word in reader: d= word[9] start = d.find('transid') d= d[start:].split(' ') new = d[0].split("=")[1] val_list.append(new) print counter(val_list)
if print "new" values trandid value not appending list , keep getting error:
error: traceback (most recent call last): file "temp.py", line 64, in <module> new = d[0].split("=")[1] indexerror: list index out of range
basically want create dictionary part of log have key value pair separated "=" sign problem part of log such url , comment can have "=" sign well.
any appreciated.