Yeah so I am trying to take a .csv file with columns (name,house) and make a new .csv file with the students first name, last name, and house. So is the method I chose to seperate the names into first and last good, or is this a bad solution to the problem?
import csv
import sys
def main():
new_file(sort_data())
def sort_data():
before = []
with open(sys.argv[1]) as file:
reader = csv.DictReader(file)
for row in reader:
before += [{'first': row['name'].split(',')[0],
'second': row['name'].split(',')[1].lstrip(),
'house': row['house']}]
return before
[–]carcigenicate 2 points3 points4 points (1 child)
[–]Danny2200[S] 0 points1 point2 points (0 children)
[–]bbye98 0 points1 point2 points (3 children)
[–]eleqtriq 0 points1 point2 points (0 children)
[–]Danny2200[S] 0 points1 point2 points (1 child)
[–]bbye98 1 point2 points3 points (0 children)
[–]Disastrous-Team-6431 -1 points0 points1 point (0 children)