# Upload

## *class* <mark style="color:purple;">Upload</mark>

Uploads are the interface for bringing data into Redivis. They are associated with a particular table, and can be created on any table belonging to an unreleased version of a dataset. Multiple uploads can be added to a table, in which case they are "stacked" together (equivalent to a union join, with mixed schemas supported).

## Constructors

<table data-header-hidden><thead><tr><th width="342">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/WcxdjQyYi2QpgLtDCzRY"><strong><code>table.upload</code></strong></a>(upload_name)</td><td>Construct a reference to an upload. <code>upload_name</code> is optional, and will be inferred based on the file name if not provided (for non-file uploads, the default name will be set to the current timestamp).</td></tr></tbody></table>

## Examples

[See more upload examples ->](/api/client-libraries/redivis-python/examples/uploading-data.md)

{% tabs %}
{% tab title="Upload tabular file" %}

```python
dataset = redivis.user("user_name").dataset("dataset_name", version="next")
table = dataset.table("table_name")

upload = table.upload().create(
        "./data.csv",           # Path to file, data frame, bytes, etc
        type="delimited",       # Inferred from file extension if not provided
        remove_on_fail=True,    # Remove the upload if a failure occurs
        wait_for_finish=True,   # Wait for the upload to finish processing
        raise_on_fail=True      # Raise an error on failure
    )
```

{% endtab %}

{% tab title="Upload multiple files" %}

```python
dataset = redivis.user("user_name").dataset("dataset_name", version="next")
table = dataset.table("table_name")

for filename in os.listdir("/path/to/data/directory"):
    upload = table.upload().create(
        os.path.join(directory, filename)
    )
```

{% endtab %}
{% endtabs %}

## Attributes

| **`table`**      | A reference to the [Table](/api/client-libraries/redivis-python/reference/table.md) instance that constructed this upload.                                                                               |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`properties`** | A dict containing the [API resource representation of the upload](/api/resource-definitions/upload.md#get). This will only be populated after certain methods are called, particularly the `get` method. |

## Methods

<table data-header-hidden><thead><tr><th width="430">Name</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/d8i3JtO10VqneAEBjcW7"><strong><code>Upload.create</code></strong></a>(data[, ...])</td><td>Create an upload with the provided data and/or configuration.</td></tr><tr><td><a href="/pages/RpsamL4uiWJo7ZlOXtxK"><strong><code>Upload.delete</code></strong></a>()</td><td>Delete an upload.</td></tr><tr><td><a href="/pages/YEvPjJqYGNjEJAOdmy8I"><strong><code>Upload.exists</code></strong></a>()</td><td>Check whether an upload exists.</td></tr><tr><td><a href="/pages/KcT6nzpiAjf07FlM61pT"><strong><code>Upload.get</code></strong></a>()</td><td>Fetch an upload and populate <code>upload.properties</code></td></tr><tr><td><a href="/pages/M6zOjQwLnWKULPlWOrHn"><strong><code>Upload.insert_rows</code></strong></a>(rows, *[, update_schema])</td><td>Insert rows into an upload of type <code>"stream"</code></td></tr><tr><td><a href="/pages/qbMXybSSBakBjZslZFN7"><strong><code>Upload.list_variables</code></strong></a>([max_results])</td><td>List the <a href="/pages/sIardnXGFnVA5S0B7sVi">variables</a> associated with a given upload.</td></tr><tr><td><a href="/pages/qPDznsT6SrIeFTINl7JG"><strong><code>Upload.to_*</code></strong></a>([max_results, *, ...])</td><td>Various methods to read data out of an imported (but not yet released) upload. Mirrors the various <a href="/pages/RTo6J5q5TcwH3Rn34708">Table.to_*</a> methods (e.g., <code>upload.to_pandas_dataframe()</code></td></tr><tr><td><a href="/pages/B2yyoLyHfnXnvHvPgS0x"><strong><code>Upload.variable</code></strong></a>(name)</td><td>Reference a <a href="/pages/sIardnXGFnVA5S0B7sVi">Variable</a> within this upload.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/api/client-libraries/redivis-python/reference/upload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
