Lab – Working With Files

Open a file cust.csv :

id,name,city
10,eli,ashdod
20,avi,haifa
30,dani,tel aviv
40,yosi,yafo

And orders file:

id,cust_id,date,sum
1,10,1/1/17,123
2,20,2/4/16,190
3,10,2/3/17,2455
4,30,9/2/17,240
5,40,1/5/16,200
6,30,1/2/17,1240
7,40,14/5/16,1200

1.  Create an interactive app: ask for customer name (using input function) and display the total orders for the customer

  • Create a function getid(name) -> return customer id by name
  • Create a function getorders(custid) -> return list of all orders for customer id (try to use filter function with lambda expression)
  • Create a function calcsum(listoforders) -> return total sum of orders  
  • Write the main loop and use the above functions

2.  Create a file summery.txt with customer name and total orders:

eli:2578
avi:190
dani:1480
yosi:1400