2 # -*- coding: utf-8 -*-
7 sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
8 sys.stderr = codecs.getwriter('utf_8')(sys.stderr)
11 ga_data_path = sys.argv[1]
12 otp_data_path = sys.argv[2]
14 sys.exit(sys.argv[0] + " <ga file> <otp file>")
16 ga_file = codecs.open(ga_data_path, "r", "utf_8")
21 #Page Title,Pageviews,Unique Pageviews,Avg. Time on Page,Bounce Rate,% Exit,$ Index
23 items = row.strip().split( "," )
25 ga_dict[title] = items
26 ga_titles.append(title)
30 otp_file = codecs.open(otp_data_path, "r", "utf_8")
35 #url,title,editor,PVs,comments,date,tags
36 items = row.strip().split( "," )
38 for ga_title in ga_titles:
39 if ga_title.find( items[1] ) != -1:
40 ga_info = ga_dict.pop(ga_title)
41 ga_info.append( items[5] )
42 ga_info.append( items[6] )
43 updated_dict[ga_title] = ga_info
46 sys.stderr.write( "! %s - %s\n" % (items[1],items[5]) )
49 for title in updated_dict:
50 print title, ",", ",".join( updated_dict[title] )
53 print title, ",", ",".join( ga_dict[title] )