sorted_players['QB'] = [] sorted_players['RB'] = [] sorted_players['WR'] = [] sorted_players['TE'] = [] sorted_players['DEF'] = [] for player in players: position = player['position'].upper() sorted_players[position].append(player) return sorted_players if __name__ == '__main__': logging.basicConfig(level=logging.INFO) p = FantasyFootballCalculatorParser() s = FantasyFootballCalculatorScraper() parser = argparse.ArgumentParser() parser.add_argument('--league_size', help='Number of team in league', required=True, type=int) parser.add_argument('--draft_position', help='Your pick number', required=True, type=int) parser.add_argument('--rounds', help='Number of rounds in draft', required=True, type=int) args = vars(parser.parse_args()) # get the XML and parse into player dictionaries content = s.get_adp() players = p.adp(content, args['league_size']) players = sort_by_position(players) for pick in all_picks(args['draft_position'], args['league_size'], args['rounds']): print 'Pick %d' % pick
writer = csv.DictWriter(outfile, fieldnames=headers) writer.writeheader() for item in data: writer.writerow(item) def save_json(fn, data): with open(fn, 'w') as outfile: json.dump(data, outfile, indent=4, sort_keys=True) if __name__ == '__main__': logging.basicConfig(level=logging.INFO) p = FantasyFootballCalculatorParser() s = FantasyFootballCalculatorScraper() parser = argparse.ArgumentParser() parser.add_argument('--save_csv', help='Filename to save to', required=False) parser.add_argument('--save_json', help='Filename to save to', required=False) args = vars(parser.parse_args()) content = s.get_projections() players = p.projections(content) #logging.info(pprint.pformat(players))
with open(fn, 'w') as outfile: writer = csv.DictWriter(outfile, fieldnames=headers) writer.writeheader() for item in data: writer.writerow(item) def save_json(fn, data): with open(fn, 'w') as outfile: json.dump(data, outfile, indent=4, sort_keys=True) if __name__ == '__main__': logging.basicConfig(level=logging.INFO) p = FantasyFootballCalculatorParser() s = FantasyFootballCalculatorScraper() parser = argparse.ArgumentParser() parser.add_argument('--save_csv', help='Filename to save to', required=False) parser.add_argument('--save_json', help='Filename to save to', required=False) args = vars(parser.parse_args()) content = s.get_projections() players = p.projections(content) #logging.info(pprint.pformat(players)) print json.dumps(players) jsonfn = args.get('save_json', None) if jsonfn: