All pastes #394687 Raw Edit

Anonymous

public python v1 · immutable
·published 2007-03-14 14:49 UTC
rendered paste body
#!/usr/bin/python#feed it a file in koi8-r encoding!import sysif len(sys.argv) < 2:	print 'Usage: ./parse.py <filename>'	sys.exit(-1)data = open(sys.argv[1]).readlines()lines_file = open('lines', 'w')total = 0for line in data:	line = line.upper()	linenumbers = []	for i in range(1, len(line) + 1):		if line[-i] == '\xf4' and line[-i - 1] == '\xfb':			p = i + 2			while line[-p] in ' 0123456789':				p += 1			amount = line[-p + 1:-i -1].strip()			linenumbers.append(amount)			total += int(amount)	lines_file.write(' '.join(linenumbers) + '\n')lines_file.close()open('total', 'w').write(str(total) + '\n')