Reputation: 745
I am given a csv that looks like this:
Jason,Bourne,1234567781123,55.123,45.23412,1234 MapleWay,Chicago,IL,54321
Jane,Bourne,1234567781123,77.123,45.23412,1234 MapleWay,Chicago,IL,12345
I have three objectives:
This is what I have thus far... am I on the right track? I am pretty stuck....thanks in advance.
self.lastNames=[]
self.phoneNumbers=[]
pass
def analyzeRow(self,row):
#called once for every row in csv. Process row and store data in Class to be queried
print('line[{}] = [].'.format(i,row))
def getLastames(self):
#return list of unique last names found in alphabetical order
def phoneNumber(self,phone):
#lookup/return name associated with provided phone number
Upvotes: 0
Views: 24
Reputation: 5015
Let's say df
is your dataframe:
To process each row in the csv:
import pandas as pd
pd.read_csv('your_csv.csv', header=0, sep=',')
df.columns=['name','surname','int1', 'float1', 'float2', 'int2','neighborhood', 'city', 'state','zip_code']
To get all of the unique last names
df.surname.unique()
Be able to lookup the name associated by putting in a number
df.name[df.int1==1234567781123]
Upvotes: 1