jiewei
Arch-Supremacy Member
- Joined
- Oct 21, 2006
- Messages
- 11,970
- Reaction score
- 0
Hi all,
Currently i'm creating a simple text-based database of information about people
I have a csv file which consist of 3 rows , row 1 2 and 3 is as such:
Name Address Telephone Birthday
John Konon Ministry of Moon Walks 4567882 27-Feb
Stacy Kisha Ministry of Man Power 1234567 17-Jan
But i wanted to make it
[('John Cleese', 'Ministry of Moon Walks', '4567882', '27-Feb'),
( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')]
I manage to code out the things i want but was told not to use csv library because it will make the assignment become too easy.
My starting code was:
so now my code is :
and the output now is:
i need to make it to
can someone show me guidance to this issue
Thanks all
Currently i'm creating a simple text-based database of information about people
I have a csv file which consist of 3 rows , row 1 2 and 3 is as such:
Name Address Telephone Birthday
John Konon Ministry of Moon Walks 4567882 27-Feb
Stacy Kisha Ministry of Man Power 1234567 17-Jan
But i wanted to make it
[('John Cleese', 'Ministry of Moon Walks', '4567882', '27-Feb'),
( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')]
I manage to code out the things i want but was told not to use csv library because it will make the assignment become too easy.
My starting code was:
import csv
def loan_friends(filename='friends.csv'):
original = file('friends.csv', 'rU')
reader = csv.reader(original)
for row in reader:
print [tuple(row) for row in reader]
so now my code is :
f = open('friends.csv', 'rU')
for row in f:
print [row for (row) in f]
for row in reader:
print row
and the output now is:
Code:
['John Cleese,Ministry of Silly Walks,5555421,27-Oct\n', 'Stacy Kisha,Ministry of Man Power,1234567,17-Jan\n']
i need to make it to
Code:
[('John Cleese', 'Ministry of Moon Walks', '4567882', '27-Feb'),
( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')]
Thanks all