-
-
Save ifournight/bf580952f6a4527c9e3d to your computer and use it in GitHub Desktop.
py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
# Map row to dictionary (dictionary comprehension) | |
def player(column_names, row): | |
return {column_names[column]: data for column, data in enumerate(row) if column < len(column_names)} | |
# Map CSV file to list of dictionaries (list comprehension) | |
players = [player(['name', 'position', 'game_info', 'price'], row) for row in csv.reader(open('dk.csv', 'r'))] | |
def loadAvatarCsv(row): | |
return {'avatar_id': row[0], 'avatarsuit_id': row[2]} | |
avatar_csv = [loadAvatarCsv(row) for row in csv.reader(open('Avatar.csv', 'r'))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment