Jan-28-2018, 11:35 PM
Hi,
I've tried so many different ways to sort but nothing is working so I've just left it as fh.sort (I know that's wrong) and I'm hoping someone can figure it out.
My code is:
1 import sys
2
3 f=open(sys.argv[1]).read().split("\n")
4 fh=open(sys.argv[2], 'wr+')
5
6 length = len(f)
7
8 for n,line in enumerate(f):
9 if "----- Begin chunk -----" in line:
10 if n == length:
11 break
12 nlist = n + 1
13 print >> fh, (nlist)
14 for m,line in enumerate(f):
15 if "----- End chunk -----" in line:
16 if m == length:
17 break
18 mlist = m + 1
19 print >> fh, (mlist)
20 fh.sort
I want to output the fh file as a numerically sorted version that looks like this:
1 1
2 5
3 50
4 75
5 100
6 150
Please and thank you!
I've tried so many different ways to sort but nothing is working so I've just left it as fh.sort (I know that's wrong) and I'm hoping someone can figure it out.
My code is:
1 import sys
2
3 f=open(sys.argv[1]).read().split("\n")
4 fh=open(sys.argv[2], 'wr+')
5
6 length = len(f)
7
8 for n,line in enumerate(f):
9 if "----- Begin chunk -----" in line:
10 if n == length:
11 break
12 nlist = n + 1
13 print >> fh, (nlist)
14 for m,line in enumerate(f):
15 if "----- End chunk -----" in line:
16 if m == length:
17 break
18 mlist = m + 1
19 print >> fh, (mlist)
20 fh.sort
I want to output the fh file as a numerically sorted version that looks like this:
1 1
2 5
3 50
4 75
5 100
6 150
Please and thank you!