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

Sort the included phonebook.csv file into an output list of people's names and phone numbers sorted by last name #20

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Jennyisawesome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#This is my Jenny was here program
Jenny was here
2 changes: 2 additions & 0 deletions Lesley.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Git flow is useful thank you!
I want to learn python as soon as possible maybe today.
2 changes: 2 additions & 0 deletions MiriamIsSuperman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#This is my MiriamIsSuperman program
print 'Miriam Is Superman'
22 changes: 22 additions & 0 deletions newphonebook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#Import Python modules for handling csv
import sys
import csv
import operator
#Open phonebook.csv file
myfile = csv.reader(open("phonebook.csv", 'rU'), delimiter=',', dialect=csv.excel_tab)
header=myfile.next()

#sort the data
sort = sorted(myfile, key=operator.itemgetter(1))

#Write result into a new csv file
with open("new_phonebook.csv", "wb") as f:
fileWriter = csv.writer(f, delimiter = ',')
for row in sort:
fileWriter.writerow(row)

#return information from file
for first_name, last_name, phone1 in sort:
print first_name, phone1


1 change: 1 addition & 0 deletions phonebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
fileWriter.writerow(header)
for row in sorted_data:
fileWriter.writerow(row)
#I don't know how to edit python in terminal
22 changes: 22 additions & 0 deletions shikhaPhoneBook.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
15 changes: 15 additions & 0 deletions shikhaPhoneBook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Import Python modules for handling csv
import sys
import csv
import operator
#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(1))
with open("shikhaPhoneBook.csv", "wb") as my_file:
fileWriter = csv.writer(my_file, delimiter=',')
if header:
fileWriter.writerow(header)
for row in sorted_data:
fileWriter.writerow(row)