Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sorty #24

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions newphonebook.csv
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
first_name,last_name,phone1
Abel,Maclead,631-335-3414
Art,Venere,856-636-8749
Cammy,Albares,956-537-6195
Donette,Foller,513-570-1893
Gladys,Rim,414-661-9598
Graciela,Ruta,440-780-8425
James,Butt,504-621-8927
Josephine,Darakjy,810-292-9388
Kiley,Caldarera,310-498-5651
Kris,Marrier,410-655-8723
Lenna,Paprocki,907-385-4412
Leota,Dilliard,408-752-3500
Mattie,Poquette,602-277-4385
Meaghan,Garufi,931-313-9635
Minna,Amigon,215-874-1229
Mitsue,Tollner,773-573-6914
Sage,Wieser,605-414-2147
Simona,Morasca,419-503-2484
Yuki,Whobrey,313-288-7937
first_name,last_name,phone1
Cammy,Albares,956-537-6195
Allen,Amber,352-867-5309
Minna,Amigon,215-874-1229
James,Butt,504-621-8927
Kiley,Caldarera,310-498-5651
Josephine,Darakjy,810-292-9388
Leota,Dilliard,408-752-3500
Donette,Foller,513-570-1893
Meaghan,Garufi,931-313-9635
Abel,Maclead,631-335-3414
Kris,Marrier,410-655-8723
Simona,Morasca,419-503-2484
Buck,Mr,555-555-1212
Lenna,Paprocki,907-385-4412
Mattie,Poquette,602-277-4385
Gladys,Rim,414-661-9598
Graciela,Ruta,440-780-8425
Mitsue,Tollner,773-573-6914
Art,Venere,856-636-8749
Yuki,Whobrey,313-288-7937
Sage,Wieser,605-414-2147
23 changes: 5 additions & 18 deletions phonebook.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
#Import Python modules for handling csv
import sys
import csv
import operator
#Marly was here
#Amber was here
#Toby was here
#Open phonebook.csv file
with open("phonebook.csv", "rU") as myfile:
checkreader = csv.reader(myfile)
header = next(checkreader)
sorted_data = sorted(checkreader, key = operator.itemgetter(0))
with open("newphonebook.csv", "wb") as my_file:
fileWriter = csv.writer(my_file, delimiter=',')
if header:
fileWriter.writerow(header)
for row in sorted_data:
fileWriter.writerow(row)
import pandas as pd

df = pd.read_csv('phonebook.csv')
df.sort_values(by='last_name', inplace=True)
df.to_csv('newphonebook.csv', index=False)