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__':

    logger = logging.getLogger(__name__)
    s = FFNerdNFLScraper(os.environ.get('FFNERD_API_KEY'))
    p = FFNerdNFLParser(overall_rank_max=400)

    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())

    projections, rankings = s.get_projections()
    players = p.projections(projections=projections, rankings=rankings)

    # do name matching
    # save parsing time
    mfl_json = 'mfl_players.json'
    if os.path.exists(mfl_json):
        with open(mfl_json) as data_file:
            players_match_from = json.load(data_file)
Exemple #2
0
        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__':

    logger = logging.getLogger(__name__)
    s = FFNerdNFLScraper(os.environ.get('FFNERD_API_KEY'))
    p = FFNerdNFLParser(overall_rank_max=400)

    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())

    projections, rankings = s.get_projections()
    players = p.projections(projections=projections, rankings=rankings)

    # do name matching
    # save parsing time
Exemple #3
0
import json
import logging
import os
import pprint

from ffnerd_projections.FFNerdNFLScraper import FFNerdNFLScraper
from ffnerd_projections.FFNerdNFLParser import FFNerdNFLParser

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
api_key = os.environ.get('FFNERD_API_KEY')

if api_key:
    s = FFNerdNFLScraper(api_key=api_key)
    logging.debug(dir(s))
    content = s.get_projections()
    logging.debug(json.dumps(content, indent=4, sort_keys=True))
    p = FFNerdNFLParser()
    players = p.projections(content=content)
    pprint.pprint(players, indent=4)