Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
380 views

Python-Module03-Case Study03

1. GoodsKart acquired another ecommerce company called FairDeal which has its own customer database format. 2. To reduce costs, GoodsKart wants to integrate the customer databases but must first convert FairDeal's customer data into GoodsKart's customer format. 3. The document provides code to read in FairDeal's customer data, format it, and create a customer class to check if a customer name is in FairDeal's customer list or the blocklist.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
380 views

Python-Module03-Case Study03

1. GoodsKart acquired another ecommerce company called FairDeal which has its own customer database format. 2. To reduce costs, GoodsKart wants to integrate the customer databases but must first convert FairDeal's customer data into GoodsKart's customer format. 3. The document provides code to read in FairDeal's customer data, format it, and create a customer class to check if a customer name is in FairDeal's customer list or the blocklist.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Module 3

Deep Dive - Functions, OOPs, Modules, Errors and Exceptions


Case Study - III

1. Business challenge/requirement
GoodsKart—largest ecommerce company of Indonesia with revenue of $2B+
acquired another ecommerce company FairDeal. FairDeal has its own IT system to
maintain records of customer, sales etc. For ease of maintenance and cost savings
GoodsKart is integrating customer databases of both the organizations hence customer
data of FairDeal has to be converted in GoodsKart Customer Format.

Answer:

import pandas as pd

df = pd.read_csv('FairDealCustomerData.csv',header=None)

df[1] = df[1]+df[0]

del df[0]

#str.strip() is similar to trim

fairCustList = list(df[df[2]==0][1].str.strip())

blockcustlist= list(df[df[2]==1][1].str.strip())

fairCustList

class customer:

customers = []

def __init__(self,custlst):

self.customers = custlst

def __del__(self):

self.customers =[]

def IsFair(self,name):

if name in self.customers:

print('{0} is a fair customer'.format(name))

else:

raise Exception
try:

fr = customer(fairCustList)

fr.IsFair(input('Enter Customer Name for an Order:'))

# print(fr.customers)

except:

print('Sorry!!Input Customer is a blacklisted.')

******

You might also like