Extremely simple, but disappointing ... I import data that is already structured as a list, but no matter what I try to use python, it reads it as a string.
How to make ranks [] a valid list instead of a string? It seems like with the wording of this data it should be almost automatic, instead he fights me like crazy and does the ranks [0] = "["
data set:
['accounting', 5, 9, 11, 0, 0]
['polysci', 1, 2, 24, 0, 0]
script:
file = open("sub_ranks.txt","r+")
ranks = []
for line in file:
ranks = line
group = ranks[0]
if ranks[1] >= 15:
print group
f = open("results.txt","a")
f.write(group+"\n")
f.close()
source
share