Permalink
Browse files

camelcase_to_snakecase: Replace spaces with underscores

…instead of stripping them.  All of the lookup tables in source-data/,
seem to expect underscores instead of spaces.

For my particular case, the region "french polynesia" isn't in
source-data/geo_regions.tsv but "french_polynesia" is.  Warnings about
this case and other country/region cases disappeared after this change.
  • Loading branch information...
tsibley committed Jun 7, 2018
1 parent 75a1baf commit 93313cb0800b4a415b084750c94b38769ace8dbf
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/utils/misc.py
@@ -8,7 +8,7 @@ def camelcase_to_snakecase(name):
'''
if name is not None:
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower().replace(" ","")
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower().replace(" ", "_")

def snakecase_to_camelcase(name):
if name is not None:

0 comments on commit 93313cb

Please sign in to comment.