def read_and_upload()

in src/cadet.py [0:0]


def read_and_upload(source_path, file_type, client, collection_link):
    """
    Reads the CSV `source` of type `file_type`, connects to the `client` to the
    database-collection combination found in `collection_link`
    """
     # Stats read for percentage done
    source_size = os.stat(source_path).st_size
    click.echo('Source file total size is: %s bytes' % source_size)
    with open(source_path, 'r') as source_file:
        click.echo('Starting the upload')
        document = {}
        csv_reader = csv.reader(source_file, delimiter=DELIMITERS[file_type])
        line_count = 0
        with click.progressbar(length=source_size, show_percent=True) as status_bar:
            for row in csv_reader:
                if line_count == 0:
                    csv_cols = row
                    line_count += 1
                else:
                    for ind, col in enumerate(csv_cols):
                        document[col] = row[ind]
                    try:
                        client.UpsertItem(collection_link, document)
                        status_bar.update(sys.getsizeof(row))
                    except:
                        raise click.ClickException('Upload failed')
        click.echo('Upload complete!')