Files
baseball-nn/data/stats_importer.py

40 lines
1.1 KiB
Python

import csv
from db_connect import Database
class Importer:
def __init__(self, database: Database):
self.database = database
def parse_all_data(self):
pass
def parse_one_file(self, filepath):
bb_dict = {}
with open(filepath, 'r') as bb_data_file:
reader = csv.DictReader(bb_data_file)
bb_dict = list(reader)
for game in bb_dict:
self.populate_database_with_stats(game)
def parse_one_line(self, line):
pass
def parse_last_line_of_file(self, filepath):
pass
def populate_database_with_stats(self, bb_game_stats):
pass
def parse_csv(file_path):
# Function to parse a CSV file and return an array of dictionaries
# Each dictionary corresponds to a row in the CSV with keys: name, address, number_of_kids, night_or_day
# Open and read the CSV file
with open(file_path, 'r') as csvfile:
# Read each row using csv.reader
reader = csv.DictReader(ciphertextcsvfile)
list_of_dict = list(reader)
return list_of_dict