# Import Data

When you have a lot of external data to input at once, it might be easier to organise it in a spreadsheet or use a script. In those cases, you can import the resulting CSV or JSON directly into FrontierNav.

![Importing a CSV that creates new rows for any unmatched names. (Old interface)](https://2168947178-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLQL2YrEAp0s7HxJmP8%2F-MLhFk6tzYE7yLYPtej8%2F-MLhHKqrGMNh6XNnh9Ed%2Fimportskillram.gif?alt=media\&token=d8622953-5b5b-4ce4-88d1-d4ebfecffda8)

## Prepare an import

Before trying to import anything, use [data-tables](https://docs.frontiernav.net/editing-data/data-tables "mention") to make sure you have created all the Entity Types and Properties that you plan to import.

You might want to [#save-changes](https://docs.frontiernav.net/making-changes#save-changes "mention") in case your import doesn't go to plan or you can [#rewind-changes](https://docs.frontiernav.net/making-changes#rewind-changes "mention").

### Supported File Formats

#### CSV

CSVs are a file format that most spreadsheet software can export to so check your "Save As..." or "Export" options and choose "CSV". You MUST have column headings.

```
Name,Price
Potion,20
Sword,500
```

#### JSON

If you're using scripts, you can export to an array of JSON objects.

```
[
  {
    "name": "Potion",
    "price": 20 
  },
  {
    "name": "Sword",
    "price": 500
  }
]
```

### Prepare relationship data

Often a single spreadsheet column can have multiple values. For example:

<table><thead><tr><th width="189">Enemy</th><th>Item Drops</th></tr></thead><tbody><tr><td>Enemy 1</td><td>Potion, Sword</td></tr><tr><td>Enemy 2</td><td>Potion, Antidote, Sword</td></tr></tbody></table>

It's best to split these spreadsheet columns up before importing them. So you can have "Item Drop 1", "Item Drop 2", "Item Drop 3".

| Enemy   | Item Drop 1 | Item Drop 2 | Item Drop 3 |
| ------- | ----------- | ----------- | ----------- |
| Enemy 1 | Potion      | Sword       |             |
| Enemy 2 | Potion      | Antidote    | Sword       |

You can then apply multiple Relationship setters to combine them under a single Relationship property. Columns with no value will be safely ignored. If you do not want to do this manually, you can use a spreadsheet formula like `SPLIT(B2, ", ")`.

## Start an import

To start an import:&#x20;

1. Go to the table you want to import data to.
2. Click the triple dot dropdown menu on the top right and choose "Import data".
3. Choose a file and you will be presented with a form.

![The default import form](https://2168947178-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLQL2YrEAp0s7HxJmP8%2F-MLhieTy6olR7x64tvlY%2F-MLhm4g-xowFoZ_U0Uol%2FScreenshot%20from%202020-11-09%2016-12-47.png?alt=media\&token=c1affac9-50f2-4919-bffd-e13faafbd072)

This form may look complicated at first glance. Essentially the import process will:

1. Go through each row of your data sequentially.
2. **Match** each row to an Entity.
3. **Set** properties on the matched Entity from the given columns.

First select the Entity Type to import into. After that, select the criteria to **match** an Entity to a row in your file. Finally, **set** the matched Entity's properties to columns in that row.

Once you are ready, press the "Import" button. Once you are happy with the import, remember to [#open-a-change-request](https://docs.frontiernav.net/change-requests#open-a-change-request "mention").

### Create or ignore unmatched entities

If a row does not match any entity, by default it will be **ignored**. You can choose to **create** an Entity instead. However, if doing so, you need to **set** a unique Name property. The import will fail if there is no Name.

### Create or ignore unmatched relationships

If you are **setting** Relationships to an Entity and it does not match an existing Relationship, by default it will be **ignored**. You can choose to **create** a new Relationship instead.

Unlike entities, you do not need a Name to create a Relationship, but a target Entity must **match**. If you want to **create** the target Entity too, you must **match** a unique Name otherwise it will be ignored.

Existing relationships are not removed by default. You can choose to **replace** all existing relationships with the new relationship.

### Handle errors

If a row fails to import, an error will be shown and the import will immediately stop. No changes from the import will be applied.
