def run(config):
    """
    This script will create an SQL database and the corresponding ontology,
    given a .csv or .tsv file containing the data.
    
    It will produce a .db file (the database) and a .json file (the ontology),
    reflecting the settings in the configuration file.
    
    Warning: The first column of the .csv / .tsv will be treated as the primary
             key.
    
    """

    db_creator = CreateSQLiteDB()

    plato_path = ''

    if not os.path.isfile(config):
        # Look for the config file in the example
        import plato

        # __file__ points to __init__.py, which is 11 characters but we
        # want the root path only.
        plato_path = "/".join(plato.__file__.split("/")[:-1])[:-6] + '/'
        config = plato_path + 'example/config/domain/' + config

    args = db_creator.arg_parse(config)

    if not args:
        raise ValueError('Terminating')

    csv_filename = plato_path + args['GENERAL']['csv_file_name']
    table_name = args['GENERAL']['db_table_name']
    db_name = plato_path + args['GENERAL']['db_file_path']
    ontology_name = plato_path + args['GENERAL']['ontology_file_path']

    informable_slots = []
    requestable_slots = []
    system_requestable_slots = []

    if 'ONTOLOGY' in args:
        if 'informable_slots' in args['ONTOLOGY']:
            informable_slots = args['ONTOLOGY']['informable_slots']

        if 'requestable_slots' in args['ONTOLOGY']:
            requestable_slots = args['ONTOLOGY']['requestable_slots']

        if 'system_requestable_slots' in args['ONTOLOGY']:
            system_requestable_slots = \
                args['ONTOLOGY']['system_requestable_slots']

    column_names = []

    MAX_DB_ENTRIES = -1

    delim = '\t' if csv_filename.split('.')[1] == 'tsv' else ','

    # Read csv entries and create items
    with open(csv_filename) as csv_input:
        csv_reader = csv.reader(csv_input, delimiter=delim)

        for entry in csv_reader:
            column_names = entry

            if not informable_slots:
                # Skip the primary key (first column by default)
                informable_slots = column_names[1:]

            if not requestable_slots:
                requestable_slots = column_names[1:]

            if not system_requestable_slots:
                system_requestable_slots = column_names[1:]

            break

    # Warning! This treats all entries as strings by default
    sqlcmd_create_table = 'CREATE TABLE IF NOT EXISTS ' + \
                          table_name + '(' + column_names[0] + \
                          ' text PRIMARY KEY,' + \
                          ' text,'.join(
                              [column_names[c]
                               for c in range(1, len(column_names))]) \
                          + ');'

    # Create a database connection
    conn = db_creator.create_sql_connection(db_name)
    with conn:
        if conn is not None:
            # Create the table
            db_creator.create_sql_table(conn, sqlcmd_create_table)

        else:
            print("Error! cannot create the database connection.")

        # Read csv entries and create items
        with open(csv_filename) as csv_input:
            csv_reader = csv.reader(csv_input, delimiter=delim)
            first_entry = True

            punctuation = string.punctuation.replace('$', '')
            punctuation = punctuation.replace('-', '')
            punctuation = punctuation.replace('_', '')
            punctuation = punctuation.replace('.', '')
            punctuation = punctuation.replace('&', '')
            punctuation_remover = str.maketrans('', '', punctuation)

            print('Populating database ')
            entries_count = 1

            for entry in csv_reader:
                # Discard first entry (column names)
                if first_entry:
                    first_entry = False

                else:
                    # Create item
                    sql_cmd = \
                        "INSERT INTO " + table_name + '(' + \
                        ','.join([c for c in column_names]) + ')' + \
                        " VALUES(" + ','.join(
                            ['?' for c in column_names]) + \
                        ')'

                    # Round to one decimal digit
                    entry = [str(round(float(e), 1)) if
                             db_creator.check_float(e) else e for e in entry]

                    # Remove non-ascii characters
                    entry = \
                        [str(''.join(i for i in e if
                                     ord(i) < 128)).replace('\"', '')
                         for e in entry]
                    entry = [e.replace('\'', '') for e in entry]

                    # Remove punctuation
                    entry = [e.rstrip().lower().translate(punctuation_remover)
                             for e in entry]

                    # Replace empty values with None
                    # Put an actual string here so the slot entropy
                    # calculation can take
                    # the absence of values into account
                    entry = [e if e else 'None' for e in entry]

                    cur = conn.cursor()
                    cur.execute(sql_cmd, tuple(entry))

                    entries_count += 1
                    if entries_count % 10000 == 0:
                        print(f'(added {entries_count} entries)')

                    if 0 < MAX_DB_ENTRIES <= entries_count:
                        break

    print(f'{table_name} database created with {entries_count} items!\n'
          f'Creating ontology...')

    db_creator.create_ontology(conn, table_name, ontology_name,
                               informable_slots, requestable_slots,
                               system_requestable_slots)

    print(f'{table_name} ontology created!')

    This script will create an SQL database and the corresponding ontology,
    given a .csv or .tsv file containing the data.
    
    It will produce a .db file (the database) and a .json file (the ontology),
    reflecting the settings in the configuration file.
    
    Warning: The first column of the .csv / .tsv will be treated as the primary
             key.
    
    
plato/domain/create_domain_sqlite_db.py