Skip to content

Instantly share code, notes, and snippets.

@mactanxin
Created April 16, 2012 06:22
Show Gist options
  • Save mactanxin/2396672 to your computer and use it in GitHub Desktop.
Save mactanxin/2396672 to your computer and use it in GitHub Desktop.
itunes.awk
#!/usr/bin/awk -f
BEGIN{
FS="\t"
OFS=","
}
{
Product_Type=$7;
App_name=$3;
Customer_mount=$8;
split($10,date_array,"/");
dt=date_array[3]""date_array[1]""date_array[2];
version = $6;
if(Product_Type ~ /1|1F|1T|F1/){
if(App_name=="YOUKU_PLAYER_001"){
# phone_download += Customer_mount;
a["iphone"][version]["download"]+=Customer_mount;
}else if(App_name=="YouKu HD"){
# pad_download += Customer_mount;
a["ipad"][version]["download"]+=Customer_mount;
}else{
# paike_download += Customer_mount;
a["paike"][version]["download"]+=Customer_mount;
}
}else if(Product_Type ~ /7|7F|7T|F7/){
if(App_name=="YOUKU_PLAYER_001"){
# phone_update += Customer_mount;
a["iphone"][version]["update"]+=Customer_mount;
}else if(App_name=="YouKu HD"){
# pad_update += Customer_mount;
a["ipad"][version]["update"]+=Customer_mount;
}else{
# paike_update += Customer_mount;
a["ipad"][version]["update"]+=Customer_mount;
}
}else{
next;
}
b[a["iphone"][version]["download"]]=a["iphone"][version]["update"];
b[a["ipad"][version]["download"]]=a["ipad"][version]["update"];
b[a["paike"][version]["download"]]=a["paike"][version]["update"];
}
END{
# printf("%s,%d,%d,%d,%d,%d,%d",dt,phone_download,pad_download,paike_download,phone_update,pad_update,paike_update)
for(i in a){
for(j in a[i]){
for(k in a[i][j]){
print i,j,k,a[i][j][k]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment