class ManipulateCSV:
  def __init__(self, allThreads, userJoins, userNames):
    self.dataHandler = DataHandler(allThreads, userJoins)
    self.dataHandler.loadActiveForums()
    self.dataHandler.loadUsernames(userNames)
    #self.tokenizedCSV = self.dataHandler.getTokenizedCSV()
    self.requiredData = []
  
  def preparePosts(self, UsersCombsMonths, UserMonthCombScores, outFile):
    posts = self.dataHandler.getRequiredPostsFromSample(UsersCombsMonths)
    outFile = open(outFile, 'w')
    writer = csv.writer(outFile)
    count = 1
    for post in posts:
      user = post[1]
      month = post[2]
      comb = post[3]
      #print user, month, comb, UserMonthCombScores[user][month][comb]
      try:
        cripsScore = UserMonthCombScores[user][month][comb][0]
        expectedCripsScore = UserMonthCombScores[user][month][comb][1]
        post.extend([cripsScore, expectedCripsScore])
        post.insert(0, count)
        writer.writerow(map(lambda x:str(x), post))
      except:
        continue 
      count += 1
    outFile.close()
 def __init__(self, allThreads, userJoins, userNames):
   self.dataHandler = DataHandler(allThreads, userJoins)
   self.dataHandler.loadActiveForums()
   self.dataHandler.loadUsernames(userNames)
   #self.tokenizedCSV = self.dataHandler.getTokenizedCSV()
   self.requiredData = []