Skip to content

Instantly share code, notes, and snippets.

@mtholder
Created December 12, 2019 00:08
Show Gist options
  • Select an option

  • Save mtholder/6df8b6142510c81f857af2031dcbd803 to your computer and use it in GitHub Desktop.

Select an option

Save mtholder/6df8b6142510c81f857af2031dcbd803 to your computer and use it in GitHub Desktop.
takes a path to an Open Tree NexSON. writes a element of python dict mapping the filename to a frozenset of mapped OTT Ids
#!/bin/bash
fp=$1
fn=$(basename $fp)
if ! test -f $fp ; then
echo "$fp does not exist"
exit 1
fi
o=`grep '"^ot:ottId": ' "$fp" | sed 's/".*": //' | sort -g | sed ':a;N;$!ba;s/\n/ /g' | sed -E 's/ +/ /g'`
echo "\"${fn}\": frozenset([ ${o} ]),"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment