
December 24th, 2012, 09:00 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 10
Time spent in forums: 5 h 43 m 57 sec
Reputation Power: 0
|
|
If you execute the program within the terminal/command prompt you will see the error output
define a large file?
Stop reading the file in one go; you're consuming all the memory on the system. Read in 16MB or so chunks instead.
Code:
data = File.read(16 * 1024 * 1024)
If each line has the same format as your example where first part is always after the first ] and it is always before >, and the second part is always after the second ], then this would work.
However if the format were to change or the characters themselves contained either ] or >, thenit would break
Code:
s = '>g:1212ladassda[1212]ASSGDSGDJFGJFTDFGHNDF>g:12124[121]SAFSDSGSGDF'
a = s.split(']')
two = a[-1]
one = a[1].split('>')[0]
print([one,two])
|