def get_topic_similarities_as_csv():
 output = StringIO.StringIO()
 writer = csv.writer(output)
 writer.writerow(RECOMMENDATION_CATEGORIES)
 topic_similarities = get_topic_similarities_dict()
 for topic in RECOMMENDATION_CATEGORIES:
  topic_similarities_row = [value for (_, value) in sorted(topic_similarities[topic].iteritems())]
  writer.writerow(topic_similarities_row)
 return output.getvalue()

def get_topic_similarities_as_csv ( ) : output = StringIO . StringIO ( ) writer = csv . writer ( output ) writer . writerow ( RECOMMENDATION_CATEGORIES ) topic_similarities = get_topic_similarities_dict ( ) for topic in RECOMMENDATION_CATEGORIES : topic_similarities_row = [ value for ( _ , value ) in sorted ( topic_similarities [ topic ] . iteritems ( ) ) ] writer . writerow ( topic_similarities_row ) return output . getvalue ( )
downloads all similarities corresponding to the current topics as a string which contains the contents of a csv file .