# Turn a spreadsheet into a table Open **Add data**, choose **Turn a spreadsheet into a table**, upload the file, check the columns and select **Import**. Later files can add rows, update rows by key or replace all rows. ## What you will build [#what-you-will-build] A table in Nexus, your database, made from a spreadsheet or CSV file. You will describe its columns, add a check that keeps bad rows out, and load a second file. The original file is kept in a folder too. ## Before you start [#before-you-start] - A spreadsheet (Excel) or CSV file with a header row. - Access to add data. Owners and admins always have it; members need it given in [Data access](/docs/data/data-access). - For developers: the SDK installed and an API key. See the [Quickstart](/docs/get-started/quickstart). ## Steps [#steps] ### Open Add data [#open-add-data] Go to and choose **Turn a spreadsheet into a table**. ### Upload the file [#upload-the-file] Pick your file and the folder to keep it in. Klarety shows the **Columns found**. ### Name the table and import [#name-the-table-and-import] Check the **Table name**. If it already exists, choose **Add rows** or **Replace rows**. Select **Import**, then **Open table**. ### Describe the columns [#describe-the-columns] Add a description to each column that is not obvious ("What this column holds"). The AI in Studios and agents reads them, so good ones give better answers. ### Add a data check [#add-a-data-check] Open **Data checks** and select **Add check**, for example `order_id` is never empty, or `amount` is between 0 and 100000. Rows that fail are set aside when data is added. ### Load the next file [#load-the-next-file] For a new version of the spreadsheet, open the table, choose **Add data from a file** and pick how it loads: - **Add rows**: append the new rows. - **Update rows by key**: match rows on a column such as `order_id`, update the ones that exist and add the rest. - **Replace all rows**: the file becomes the whole table. ### Load the file [#load-the-file] ```python from klarety import Nexus nx = Nexus.connect() run = nx.ingest("orders.csv", into="orders", schema="default") print(run.run_id, run.state) ``` ### Preview before loading (optional) [#preview-before-loading-optional] `ingest_preview` shows what Klarety found in the file without loading anything: ```python print(nx.ingest_preview("orders.csv", into="orders")) ``` ### Wait for it to finish [#wait-for-it-to-finish] ```python status = nx.ingest_status(run.run_id) print(status.state) ``` ### Load the next file by key [#load-the-next-file-by-key] ```python nx.ingest("orders_week2.csv", into="orders", mode="upsert", key=["order_id"]) ``` `mode` is `auto`, `append`, `upsert` or `replace`. A file already loaded into a table is skipped unless you pass `force=True`. ### Or use the command line [#or-use-the-command-line] ```bash klarety ingest orders.csv --into orders klarety ingest orders_week2.csv --into orders --mode upsert --key order_id ``` The file becomes the whole table. If you choose it by mistake, use the table's **History** to go back. ## Check that it worked [#check-that-it-worked] Open the table from **Nexus Lakehouse**; the header shows its column and row counts. Select **Open in SQL editor** and run: ```sql SELECT COUNT(*) FROM orders ``` ```python print(nx.sql("SELECT COUNT(*) AS n FROM orders").rows) ``` The count matches the rows in your file, less any rows a check set aside. The table's **History** shows each load, with the rows it added. ## If something goes wrong [#if-something-goes-wrong] The upload dialog shows the size limit. Split the file, or load it from code or a connected source. See [Ingest data](/docs/developers/ingest). A data check set them aside. The table's check summary shows rows written and set aside in recent loads. Open the table's **History** and choose **Go back to this** on the version before the load. Every change after it is undone. See [Undo and restore](/docs/data/undo-and-restore). ## Next steps [#next-steps] - [Ask your data a question](/docs/guides/first-query): query the table you just made. - [Tables](/docs/data/tables): everything you can do with a table. - [Add data](/docs/data/add-data): other ways to bring data in. - [Send a daily report](/docs/guides/daily-report): summarise the table every morning.