Skip to content

Instantly share code, notes, and snippets.

@amontalenti
Last active September 23, 2015 13:26
Show Gist options
  • Save amontalenti/64ca33fd482fa9ad6a8f to your computer and use it in GitHub Desktop.
Save amontalenti/64ca33fd482fa9ad6a8f to your computer and use it in GitHub Desktop.
#/bin/bash
# weird one-liner to find top 100 Python imports in a project
# stolen/customized from Chris H. Wiggins @ https://gist.github.com/chrishwiggins/7518300e0d8649d8d791
find . -name '*.py' | grep -v -e '/venv/' -e '(' -e ')' | \
xargs -I % grep import % | sed -e 's/^[ ]*//' | \
grep -e '^from ' -e '^import ' | awk '{print $2}' | \
sed -e 's/^[\.]*//' | cut -d\. -f1 | tr '[A-Z]' '[a-z]' | \
sort -bfd | uniq -c | sort -nr | head -100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment