Nov-11-2016, 02:10 PM
I have to write a Python application to read a CSV input file (appsUsage.csv) and generate an output file counting the frequency of the apps usage per user. The first column of the input file contains user id (user_id) and the second column contains the name of the app (app_name). From appsUsage.csv, I have to count the frequency of apps usage on individual user basis to generate app_Rank, and transform to a new data set named appsIndividualUsage.csv with the following columns: user_id; app_name; app_Rank.
For example if appsUsage.csv has following events
If someone can help
Thank you
For example if appsUsage.csv has following events
a facebook a facebook a linkedin b google b yahoo b yahooThen appsIndividualUsage.csv would be:
a facebook 2; a linkedin 1; b google 1; b yahoo 2;Here is my code that I am struggling with :
>>>import csv with open(‘C:\\Users\\anne\\Desktop\\appsUsage.csv’, mode='r') as f_in, open(‘C:\\Users\\anne\\Desktop\\appsIndividualUsage.csv’, mode='w', newline='') as f_out: f_reader = csv.reader(f_in, dialect=csv.excel_tab) f_writer = csv.writer(f_out, dialect=csv.excel_tab) for line in reader: if line is equal then write it in writer and add a row of frequencyi totally don't know how to write the last line of my code

If someone can help

Thank you