aboutsummaryrefslogtreecommitdiff
path: root/backend/tolData/genEolNameData.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-08-20 13:16:21 +1000
committerTerry Truong <terry06890@gmail.com>2022-08-20 13:16:21 +1000
commit930c12d33e1093f874a4beb4d6376621e464e8c0 (patch)
tree381722fc3ab9ebda482cb18d29e1091458aa93da /backend/tolData/genEolNameData.py
parent8144003565797f0d18645a416b95d4365bba5fdd (diff)
Use argparse in python scripts
Diffstat (limited to 'backend/tolData/genEolNameData.py')
-rwxr-xr-xbackend/tolData/genEolNameData.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/backend/tolData/genEolNameData.py b/backend/tolData/genEolNameData.py
index 1b19a47..2c5414b 100755
--- a/backend/tolData/genEolNameData.py
+++ b/backend/tolData/genEolNameData.py
@@ -3,24 +3,21 @@
import sys, re, os
import html, csv, sqlite3
-usageInfo = f"""
-Usage: {sys.argv[0]}
-
+import argparse
+parser = argparse.ArgumentParser(description="""
Reads files describing name data from the 'Encyclopedia of Life' site,
tries to associate names with nodes in the tree-of-life database,
and adds tables to represent associated names.
Reads a vernacularNames.csv file:
- Starts with a header line containing:
- page_id, canonical_form, vernacular_string, language_code,
- resource_name, is_preferred_by_resource, is_preferred_by_eol
- The canonical_form and vernacular_string fields contain names
- associated with the page ID. Names are not always unique to
- particular page IDs.
-"""
-if len(sys.argv) > 1:
- print(usageInfo, file=sys.stderr)
- sys.exit(1)
+ Starts with a header line containing:
+ page_id, canonical_form, vernacular_string, language_code,
+ resource_name, is_preferred_by_resource, is_preferred_by_eol
+ The canonical_form and vernacular_string fields contain names
+ associated with the page ID. Names are not always unique to
+ particular page IDs.
+""", formatter_class=argparse.RawDescriptionHelpFormatter)
+parser.parse_args()
vnamesFile = "eol/vernacularNames.csv" # Had about 2.8e6 entries
dbFile = "data.db"