Created
June 30, 2013 21:38
-
-
Save xguse/5897045 to your computer and use it in GitHub Desktop.
example script to sort a file for seqanswers user marqudiego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
in_file = sys.argv[1] | |
in_data = open(in_file, 'rU') | |
data_list = [] | |
# separate and organize the data into fields | |
for line in in_data: | |
data_list.append([x.strip() for x in line.strip('\n').split('=')]) | |
# convert the number parts to actual numbers vs strings | |
for each in data_list: | |
each[1] = float(each[1]) | |
data_list.sort(key=lambda x: x[1]) | |
for each in data_list: | |
print '%s = %s' % (each[0],each[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment