#/usr/bin/python

from optparse import OptionParser
import json

parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
                  help="score file", metavar="FILE")

(options, args) = parser.parse_args()

fh = open(options.filename, 'r')

data = []

for line in fh.readlines():
  line = line.rstrip('\n\r')
  line = line.split(',')

  data.append((line[1], line[2]))

fh.close()

output = 'new_matrix.csv'

data = sorted(data, key = lambda s: int(s[0]), reverse=True)

print(data)

headers = ''
row = ''
for d in data:
  headers += d[0] + ','
  row += d[1] + ','

fh = open(output, 'a')
fh.write(headers + '\n')
fh.write(row + '\n')
fh.close()

74d8035f1629e61425137f3bc9028b3027b5a36d
<mask token>

<mask token>
parser.add_option('-f', '--file', dest='filename', help='score file',
    metavar='FILE')
<mask token>
for line in fh.readlines():
    line = line.rstrip('\n\r')
    line = line.split(',')
    data.append((line[1], line[2]))
fh.close()
<mask token>
print(data)
<mask token>
for d in data:
    headers += d[0] + ','
    row += d[1] + ','
<mask token>
fh.write(headers + '\n')
fh.write(row + '\n')
fh.close()

<mask token>
parser = OptionParser()
parser.add_option('-f', '--file', dest='filename', help='score file',
    metavar='FILE')
options, args = parser.parse_args()
fh = open(options.filename, 'r')
data = []
for line in fh.readlines():
    line = line.rstrip('\n\r')
    line = line.split(',')
    data.append((line[1], line[2]))
fh.close()
output = 'new_matrix.csv'
data = sorted(data, key=lambda s: int(s[0]), reverse=True)
print(data)
headers = ''
row = ''
for d in data:
    headers += d[0] + ','
    row += d[1] + ','
fh = open(output, 'a')
fh.write(headers + '\n')
fh.write(row + '\n')
fh.close()

from optparse import OptionParser
import json
parser = OptionParser()
parser.add_option('-f', '--file', dest='filename', help='score file',
    metavar='FILE')
options, args = parser.parse_args()
fh = open(options.filename, 'r')
data = []
for line in fh.readlines():
    line = line.rstrip('\n\r')
    line = line.split(',')
    data.append((line[1], line[2]))
fh.close()
output = 'new_matrix.csv'
data = sorted(data, key=lambda s: int(s[0]), reverse=True)
print(data)
headers = ''
row = ''
for d in data:
    headers += d[0] + ','
    row += d[1] + ','
fh = open(output, 'a')
fh.write(headers + '\n')
fh.write(row + '\n')
fh.close()

#/usr/bin/python

from optparse import OptionParser
import json

parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
                  help="score file", metavar="FILE")

(options, args) = parser.parse_args()

fh = open(options.filename, 'r')

data = []

for line in fh.readlines():
  line = line.rstrip('\n\r')
  line = line.split(',')

  data.append((line[1], line[2]))

fh.close()

output = 'new_matrix.csv'

data = sorted(data, key = lambda s: int(s[0]), reverse=True)

print(data)

headers = ''
row = ''
for d in data:
  headers += d[0] + ','
  row += d[1] + ','

fh = open(output, 'a')
fh.write(headers + '\n')
fh.write(row + '\n')
fh.close()
