Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import sys
- file = open(sys.argv[1], "r")
- text = file.read()
- games = ["Gold Rush", "Pirate Adventure", "Viking Adventure", "Pizza Master", "Pixel Painter", "Galaxy Collector"]
- def getUntilTag(pattern):
- result = ""
- for c in pattern:
- if(c!=','):
- result += c
- else:
- return result
- def readableNumber(pattern):
- return pattern[:-3]
- def readableMoney(pattern):
- return pattern
- result = ""
- for c in pattern:
- if(c!='.'):
- result += c
- else:
- return result
- for game in games:
- print("-----------------------")
- print(game)
- gameName = re.search(game, text)
- if(gameName == None):
- print("Time played: 0")
- print("Money: $0")
- else:
- textRemain = text[gameName.start():]
- secondsPlayed = re.search('"playtime"', textRemain)
- print("Time played: {0}".format(readableNumber(getUntilTag(textRemain[secondsPlayed.end()+1:secondsPlayed.end()+20]))))
- money = re.search('"payout"', textRemain)
- print("Money: ${0}".format(readableMoney(getUntilTag(textRemain[money.end()+1:money.end()+30]))))
- print("-----------------------")
- '''
- "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,
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement