@@ -0,0 +1,967 @@
+# converts article and user name to article id and user id%0Aimport csv%0A%0Awith open('cbdata-feedback.csv', 'rb') as f:%0A%09reader = csv.reader(f)%0A%09next(reader, None) # skip header%0A%09out_file = open('cbdata-feedback-anon.csv', 'wb')%0A%09writer = csv.writer(out_file, delimiter=',')%0A%0A%09user_id = 0%0A%09item_id = 0%0A%0A%09user_dict = %7B%7D%0A%09item_dict = %7B%7D%0A%0A%09# write header%0A%09writer.writerow(%5B'# user_id','url_id', 'rating', 'timeOnePage','timeMovingMouse','timeSpentVerticalScrolling'%5D)%0A%0A%09for row in reader:%0A%09%09# check if user has an id%0A%09%09if not row%5B0%5D in user_dict:%0A%09%09%09user_id = user_id + 1%0A%09%09%09user_dict%5Brow%5B0%5D%5D = user_id%0A%09%09# check if item has an id%0A%09%09if not row%5B1%5D in item_dict:%0A%09%09%09item_id = item_id + 1%0A%09%09%09item_dict%5Brow%5B1%5D%5D = item_id%0A%09%09%0A%09%09# replace username and item with ids instead%0A%09%09row%5B0%5D = user_dict%5Brow%5B0%5D%5D%0A%09%09row%5B1%5D = item_dict%5Brow%5B1%5D%5D%0A%0A%09%09# check for empty strings%0A%09%09for i in range(2,len(row)):%0A%09%09%09if row%5Bi%5D == '':%0A%09%09%09%09row%5Bi%5D = 0%0A%0A%09%09writer.writerow(row)%0A%0Af.close()%0Aout_file.close()%0A%0A%0A%0A

Convert claypool dataset to anonymous claypool dataset