data/process_data.py
def main():
    """
    Runs script step by step until it saves data in a SQL db
    :return: None
    """

    messages_filepath = ''
    categories_filepath = ''
    database_filepath = ''
    model_filepath = ''
    data_path = ''

    basedir = [f for f in os.listdir("../") if isdir(join("../", f))]

    if 'data' in basedir:

        data_path = "../data"
        data_files = [f for f in os.listdir(data_path) if isfile(join(data_path, f))]

        for file in data_files:
            if "messages.csv" in file:
                messages_filepath = f"{data_path}/{file}"

            elif "categories.csv" in file:
                categories_filepath = f"{data_path}/{file}"

            elif "data.db" in file:
                database_filepath = f"{data_path}/{file}"

    if 'models' in basedir:

        models_path = "../models"
        models_files = [f for f in os.listdir(models_path) if isfile(join(models_path, f))]

        for file in models_files:

            if "classifier.pkl" in file:
                model_filepath = f"{models_path}/{file}"


    if model_filepath:
        print("Model Path: Ok")
        print(model_filepath)
    if messages_filepath:
        print("Messages Data Path: Ok")
        print(messages_filepath)
    if categories_filepath:
        print("Categories Data Path: Ok")
        print(categories_filepath)
    if database_filepath:
        print("Database Path: Ok")
        print(database_filepath)
    else:
        database_filepath = f"{data_path}/disaster_data.db"

    try:
        print('Loading data...\n    MESSAGES: {}\n    CATEGORIES: {}'
              .format(messages_filepath, categories_filepath))
        df = load_data(messages_filepath, categories_filepath)

        print('Cleaning data...')
        df = clean_data(df)
        
        print('Saving data...\n    DATABASE: {}'.format(database_filepath))
        save_data(df, database_filepath)
        
        print('Cleaned data saved to database!')
    
    except:
        print('Please provide the filepaths of the messages and categories '\
              'datasets as the first and second argument respectively, as '\
              'well as the filepath of the database to save the cleaned data '\
              'to as the third argument. \n\nExample: python process_data.py '\
              'disaster_messages.csv disaster_categories.csv '\
              'DisasterResponse.db')

    Runs script step by step until it saves data in a SQL db
    :return: None
    
Runs script step by step until it saves data in a SQL db
Runs script step by step until it saves data in a SQL db
def main():
    messages_filepath = ''
    categories_filepath = ''
    database_filepath = ''
    model_filepath = ''
    data_path = ''
    basedir = [f for f in os.listdir("../") if isdir(join("../", f))]
    if 'data' in basedir:
        data_path = "../data"
        data_files = [f for f in os.listdir(data_path) if isfile(join(data_path, f))]
        for file in data_files:
            if "messages.csv" in file:
                messages_filepath = f"{data_path}/{file}"
            elif "categories.csv" in file:
                categories_filepath = f"{data_path}/{file}"
            elif "data.db" in file:
                database_filepath = f"{data_path}/{file}"
    if 'models' in basedir:
        models_path = "../models"
        models_files = [f for f in os.listdir(models_path) if isfile(join(models_path, f))]
        for file in models_files:
            if "classifier.pkl" in file:
                model_filepath = f"{models_path}/{file}"
    if model_filepath:
        print("Model Path: Ok")
        print(model_filepath)
    if messages_filepath:
        print("Messages Data Path: Ok")
        print(messages_filepath)
    if categories_filepath:
        print("Categories Data Path: Ok")
        print(categories_filepath)
    if database_filepath:
        print("Database Path: Ok")
        print(database_filepath)
    else:
        database_filepath = f"{data_path}/disaster_data.db"
    try:
        print('Loading data...\n    MESSAGES: {}\n    CATEGORIES: {}'
              .format(messages_filepath, categories_filepath))
        df = load_data(messages_filepath, categories_filepath)
        print('Cleaning data...')
        df = clean_data(df)
        print('Saving data...\n    DATABASE: {}'.format(database_filepath))
        save_data(df, database_filepath)
        print('Cleaned data saved to database!')
    except:
        print('Please provide the filepaths of the messages and categories '\
              'datasets as the first and second argument respectively, as '\
              'well as the filepath of the database to save the cleaned data '\
              'to as the third argument. \n\nExample: python process_data.py '\
              'disaster_messages.csv disaster_categories.csv '\
              'DisasterResponse.db')
def main ( ) : messages_filepath = '' categories_filepath = '' database_filepath = '' model_filepath = '' data_path = '' basedir = [ f for f in os . listdir ( "../" ) if isdir ( join ( "../" , f ) ) ] if 'data' in basedir : data_path = "../data" data_files = [ f for f in os . listdir ( data_path ) if isfile ( join ( data_path , f ) ) ] for file in data_files : if "messages.csv" in file : messages_filepath = f"{data_path}/{file}" elif "categories.csv" in file : categories_filepath = f"{data_path}/{file}" elif "data.db" in file : database_filepath = f"{data_path}/{file}" if 'models' in basedir : models_path = "../models" models_files = [ f for f in os . listdir ( models_path ) if isfile ( join ( models_path , f ) ) ] for file in models_files : if "classifier.pkl" in file : model_filepath = f"{models_path}/{file}" if model_filepath : print ( "Model Path: Ok" ) print ( model_filepath ) if messages_filepath : print ( "Messages Data Path: Ok" ) print ( messages_filepath ) if categories_filepath : print ( "Categories Data Path: Ok" ) print ( categories_filepath ) if database_filepath : print ( "Database Path: Ok" ) print ( database_filepath ) else : database_filepath = f"{data_path}/disaster_data.db" try : print ( 'Loading data...\n    MESSAGES: {}\n    CATEGORIES: {}' . format ( messages_filepath , categories_filepath ) ) df = load_data ( messages_filepath , categories_filepath ) print ( 'Cleaning data...' ) df = clean_data ( df ) print ( 'Saving data...\n    DATABASE: {}' . format ( database_filepath ) ) save_data ( df , database_filepath ) print ( 'Cleaned data saved to database!' ) except : print ( 'Please provide the filepaths of the messages and categories ' 'datasets as the first and second argument respectively, as ' 'well as the filepath of the database to save the cleaned data ' 'to as the third argument. \n\nExample: python process_data.py ' 'disaster_messages.csv disaster_categories.csv ' 'DisasterResponse.db' )
Runs script step by step until it saves data in a SQL db
Runs script step by step until it saves data in a SQL db
"""
    Runs script step by step until it saves data in a SQL db
    :return: None
    """
None