Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Creates a file, has print statements for debugging and uses test.dat …
…currently, but it appears to be missing 2 items in the file and 1 item in rankOrder.
  • Loading branch information
sib12004 committed Apr 21, 2016
1 parent bc82545 commit a75b702
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pagerank2.py
Expand Up @@ -6,7 +6,7 @@ import csv
import operator
import numpy as np

with open("hollins.dat", "r") as data:
with open("test.dat", "r") as data:
reader = csv.reader(data, delimiter = ' ', skipinitialspace=True)

cols = next(reader)
Expand Down Expand Up @@ -83,21 +83,23 @@ for i in range(len(finalRank)) :
string = str(finalRank[i]) #keys need to be a string
string = string[:10] #truncate to length 10
rankOrder[string] = i
print(list(rankOrder.keys())[0])
print("rankOrder keys",list(rankOrder.keys()))

#now write the answer to a text file
file = open("ranking.txt", "w")

#need to print out in order of max to min keys of the dict
#we sort finalRank from min to max
finalRank.sort()
print("finalRank sorted", finalRank)

for i in finalRank :
index = finalRank.pop()
index = str(index) #cast the index to a string
index = index[:10] #truncate to length 10
print(index)
file.write(index, urls[index])
print(type(index))
line = index + ' ' + urls[rankOrder[index]]
file.write(line)

file.close()

0 comments on commit a75b702

Please sign in to comment.