Skip to content

Instantly share code, notes, and snippets.

@rivermont
Created October 12, 2022 19:15
Show Gist options
  • Save rivermont/f73341f258ca3917e3e44ec9af023f59 to your computer and use it in GitHub Desktop.
Save rivermont/f73341f258ca3917e3e44ec9af023f59 to your computer and use it in GitHub Desktop.
iNaturalist checklist creator. Point at an iNat export file, and it prints all the species sorted by taxonomic Class.
#!/usr/bin/env python3
# iNaturalist checklist creator
# Point at an iNat export file, and it prints all the species sorted by taxonomic Class.
from operator import itemgetter
target = "observations-xxxxxx.csv"
i = 0
if __name__ == "__main__":
data = {}
with open(target, 'r') as f:
for l in f:
x = l.split(',')
try:
data[x[2].strip()].add((x[0], x[1]))
except KeyError:
data[x[2].strip()] = set([(x[0], x[1])])
for c in data:
print('\n' + c + '\n')
for x in sorted(data[c], key=itemgetter(0)):
i += 1
print(x[0] + ':', x[1])
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment