Skip to content

Instantly share code, notes, and snippets.

@oivoodoo
Created November 27, 2019 18:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oivoodoo/982afa7cdf1a9a527d254f4ad5346b0e to your computer and use it in GitHub Desktop.
Save oivoodoo/982afa7cdf1a9a527d254f4ad5346b0e to your computer and use it in GitHub Desktop.
jq -r '
[
(.userId // ""),
(.userAttributes.email // ""),
(.userAttributes.install_dt // ""),
(.userAttributes.platform // ""),
(.userAttributes.added_date // ""),
(.deviceId // ""),
(.deviceModel // ""),
(.systemVersion // ""),
(.systemName // ""),
(.priorTimeSpentInApp // ""),
(.duration // ""),
(.appVersion // ""),
(.locale // ""),
(.timezone // ""),
(.country // ""),
(.city // ""),
(.region // ""),
(.sessionId // ""),
(.sdkVersion // ""),
(.client // ""),
(.userBucket // ""),
(
[
(.states[]? | .events[]? // []) | (
[
( .name | split(" ") | .[0] ),
( .name | split(" ") | .[1]? ),
((.parameters.url // "")
| (match("campaign(%26|&)id(%3D|=)(.[^%]+)(%26|$)", .) // {{}})
| (.captures[2].string // "")),
(.parameters.url // "")
]
)
]
),
"{game_id}",
"{ds}"
] as $in
| $in[21][] as $h
| $in | del(.[21]) as $in2
| $h + $in2
| @csv
' export-* > {output_filename}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment