datasus_db.utils
Module with generic helper functions
1"""Module with generic helper functions""" 2 3import itertools 4import os 5 6 7def format_year(year, digits=2): 8 if isinstance(year, str) and not year.isnumeric(): 9 return "*" 10 11 year = str(year).zfill(digits) 12 13 return year[-digits:] 14 15 16def format_month(month): 17 if isinstance(month, str) and not month.isnumeric(): 18 return "*" 19 20 return str(month).zfill(2) 21 22 23def flatten(list_of_lists): 24 return itertools.chain.from_iterable(list_of_lists) 25 26 27def rm(file: str): 28 if os.path.exists(file): 29 os.remove(file)
def
format_year(year, digits=2):
def
format_month(month):
def
flatten(list_of_lists):
def
rm(file: str):