Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. import re
  2. import sys
  3.  
  4. file = open(sys.argv[1], "r")
  5. text = file.read()
  6.  
  7. games = ["Gold Rush", "Pirate Adventure", "Viking Adventure", "Pizza Master", "Pixel Painter", "Galaxy Collector"]
  8.  
  9. def getUntilTag(pattern):
  10. result = ""
  11. for c in pattern:
  12. if(c!=','):
  13. result += c
  14. else:
  15. return result
  16.  
  17. def readableNumber(pattern):
  18. return pattern[:-3]
  19.  
  20. def readableMoney(pattern):
  21. return pattern
  22. result = ""
  23. for c in pattern:
  24. if(c!='.'):
  25. result += c
  26. else:
  27. return result
  28.  
  29. for game in games:
  30. print("-----------------------")
  31. print(game)
  32. gameName = re.search(game, text)
  33. if(gameName == None):
  34. print("Time played: 0")
  35. print("Money: $0")
  36. else:
  37. textRemain = text[gameName.start():]
  38. secondsPlayed = re.search('"playtime"', textRemain)
  39. print("Time played: {0}".format(readableNumber(getUntilTag(textRemain[secondsPlayed.end()+1:secondsPlayed.end()+20]))))
  40.  
  41. money = re.search('"payout"', textRemain)
  42. print("Money: ${0}".format(readableMoney(getUntilTag(textRemain[money.end()+1:money.end()+30]))))
  43.  
  44.  
  45.  
  46. print("-----------------------")
  47.  
  48.  
  49.  
  50.  
  51. '''
  52. "game":"Gold Rush","avgTimePerPlay":670617,"avgCompositeRatingScore":32.871911614111724,"avgAvgCompositeRatingScore":33.521673538722574,"acceptedAt":{"year":2019,"month":9,"day":4,"calendar":"Elixir.Calendar.ISO"}},{"updatedAt":"2019-09-11T05:33:37.777559Z","sumScaledPlaytime":533813211270.30646,"subject":"3rd Grade Math","scaledPlaytime":401923892.8306109,"programId":9,"prog":"Math Sprint 2019","playtimePercentage":9.586134044354206e-4,"playtime":16335022,"periodPlaytime":17040260364.0,"period":"Pay Period 1: Aug 1, 2019 - Dec 31, 2019","payoutPercentage":9.586134044354206e-4,"payout":452.46552689351853,"ngssDciName":"3.MD.A.1","msGamesScore":24.605041415347397,"learningObjective":"Tell, Write And Measure Time In Minute Intervals","insertedAt":"2019-09-11T05:33:37.777557Z","id":47343,"gamePlayCount":52,"gamePaymentPeriodId":12,"gamePaymentPeriod":{},"gamePaymentCalculationId":332,"gamePaymentCalculation":{},"gameId":2488,"gameDeveloperId":868,
  53. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement