Skeleton of importing data from the csv

This commit is contained in:
2025-03-31 16:07:09 -04:00
parent db8f027f06
commit fa870f3f54
5 changed files with 57 additions and 2 deletions

28
data/stats_importer.py Normal file
View File

@@ -0,0 +1,28 @@
import csv
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.reader(ciphertextcsvfile)
# Initialize an empty list to store the result
result = []
# Iterate over each row in the CSV
for row in reader:
# Create a dictionary for the current row
person_dict = {
'name': row[0],
'address': row[1],
'number_of_kids': int(row[2]),
'night_or_day': row[3]
}
# Append the dictionary to the result list
result.append(person_dict)
return result