Skip to content

Instantly share code, notes, and snippets.

@milothiesen
Created January 7, 2018 20:38
Show Gist options
  • Save milothiesen/84847e87c0ab064e5aa0dccd3dde8238 to your computer and use it in GitHub Desktop.
Save milothiesen/84847e87c0ab064e5aa0dccd3dde8238 to your computer and use it in GitHub Desktop.
import pprint
arr = [{
"codec": "MPEG",
"wrapper": "mov",
"commerical": "Pro Res"
},
{
"codec": "MPEG-4",
"wrapper": "mp4",
"commerical": ""
},
{
"codec": "MPEG",
"wrapper": "m4v",
"commerical": "Random"
},
{
"codec": "MPEG-4",
"wrapper": "mp4",
"commerical": ""
},
{
"codec": "MPEG-4",
"wrapper": "mp4",
"commerical": ""
},
{
"codec": "MPEG-4",
"wrapper": "mp4",
"commerical": ""
},
{
"codec": "MPEG",
"wrapper": "mov",
"commerical": "Pro Res"
},
{
"codec": "MPEG",
"wrapper": "mov",
"commerical": "Pro Res"
},
{
"codec": "MPEG",
"wrapper": "mov",
"commerical": "Pro Res"
}]
sortedlist = []
sortedlist_with_count = []
for item in arr:
if item not in sortedlist:
sortedlist.append(item)
for x in sortedlist:
x['zCount'] = arr.count(x)
sortedlist_with_count.append(x)
for item in sortedlist_with_count:
pp = pprint.PrettyPrinter(depth=6)
pp.pprint(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment