Skip to content

Commit

Permalink
camelcase_to_snakecase: Replace spaces with underscores
Browse files Browse the repository at this point in the history
…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 8, 2018
1 parent 75a1baf commit 93313cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/misc.py
Expand Up @@ -8,7 +8,7 @@ def camelcase_to_snakecase(name):
''' '''
if name is not None: if name is not None:
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) 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): def snakecase_to_camelcase(name):
if name is not None: if name is not None:
Expand Down

0 comments on commit 93313cb

Please sign in to comment.