> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encord.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Datasets

## Create Datasets

<Note>Creating a Dataset and adding files to a Dataset are two distinct steps. [Click here](/sdk-documentation/index-sdk/sdk-add-files-to-datasets) to learn how to add data to an existing Dataset.</Note>

<Info>Datasets cannot be deleted using the SDK or the API. Use the Encord platform to delete Datasets. </Info>

The following example creates a Dataset called “Houses” that expects data hosted on AWS S3.

* Substitute `<private_key_path>` with the file path for your private key.
* Replace "Houses" with the name you want your Dataset to have.

<CodeGroup>
  ```python Example code theme={"dark"}
  # Import dependencies
  from encord import EncordUserClient
  from encord.orm.dataset import StorageLocation

  # Authenticate with Encord using the path to your private key
  user_client = EncordUserClient.create_with_ssh_private_key(
      ssh_private_key_path="<private_key_path>"
  )

  # Create a new dataset
  dataset_response = user_client.create_dataset(
      dataset_title="Houses",
      dataset_type=StorageLocation.AWS,
      create_backing_folder=False,
  )

  # Prints a CreateDatasetResponse object. Verify the Dataset creation
  print(dataset_response)

  # Print the storage location
  print(f"Using storage location: AWS")
  ```

  ```python Example output theme={"dark"}
  {
  {'title': 'Houses', 'type': 1, 'dataset_hash': 'd2bbbaed-cf33-4583-81b5-f30691abde1d', 'user_hash': 'iaDJxNNrMuQMtFPcP9oszw2OCHm2', 'backing_folder_uuid': UUID('5f8364e8-8ccd-4f9f-9066-91e055da920d')}
  }
  ```
</CodeGroup>

***

## Create a Dataset from Label Rows

Use the following script to create a new Dataset from the label rows of a specific Project.

* Replace `<private_key_path>` with the path to your private key.
* Replace `<project_hash>` with the hash of the Project containing the data units you want to create a new Dataset from.
* Replace `My new Dataset` with the name you want to give your new Dataset.

<Warning>
  If `create_backing_folder` is `True`, a mirrored Dataset is created. Mirrored Datasets sync the content of the backed Folder with the Dataset.
</Warning>

```python theme={"dark"}
# Import dependencies
from encord.orm.dataset import StorageLocation
from encord.user_client import EncordUserClient


# Authenticate with Encord using the path to your private key
user_client = EncordUserClient.create_with_ssh_private_key(
    ssh_private_key_path="<private_key_path>"
    )

# Specify a Project
project = user_client.get_project("<project_hash>")

# Get the UUIDs of the items to be added to the new Dataset
item_uuids = [lr.backing_item_uuid for lr in project.list_label_rows_v2() if "subset_me" in lr.data_title]

# Create new Dataset and link the items
response = user_client.create_dataset(
    dataset_title="My new Dataset",
    dataset_type=StorageLocation.CORD_STORAGE,
    create_backing_folder=False
)
dataset = client.get_dataset(response.dataset_hash)
dataset.link_items(item_uuids)
```

***

## List existing Datasets

Use the [EncordUserClient](/sdk-documentation/sdk-references/user_client) method to query and list the user client's Datasets.

The following example fetches all Datasets available to the user. Substitute `<private_key_path>` with the file path for your private key.

<Tip>
  The Dataset hash can be found within the URL once a Dataset has been selected:
  `app.encord.com/projects/view/\<dataset_hash>/summary` or `app.us.encord.com/projects/view/\<dataset_hash>/summary`
</Tip>

<CodeGroup>
  ```python View all Datasets theme={"dark"}
  # Import dependencies
  from encord import EncordUserClient

  # Authenticate with Encord using the path to your private key
  user_client = EncordUserClient.create_with_ssh_private_key(ssh_private_key_path='<private_key_path>')

  # List existing Datasets
  datasets = user_client.get_datasets()
  print(datasets)
  ```

  ```python View all Datasets starting with "Validation"  theme={"dark"}
  # Import dependencies
  from encord import EncordUserClient

  # Authenticate with Encord using the path to your private key
  user_client = EncordUserClient.create_with_ssh_private_key(ssh_private_key_path='<private_key_path>')

  # List existing Datasets
  datasets = user_client.get_datasets(title_like="Validation%")
  print(datasets)
  ```

  ```python Example output theme={"dark"}
  [
      {
          "dataset": DatasetInfo(
                  dataset_hash="<dataset_hash>",
                  user_hash="<user_hash>",
                  title="Example title",
                  description="Example description ... ",
                  type=0,  # encord.orm.dataset.StorageLocation
                  created_at=datetime.datetime(...),
                  last_edited_at=datetime.datetime(...)
              ),
          "user_role": DatasetUserRole.ADMIN
      },
      # ...
  ]
  ```
</CodeGroup>

<Info>The *type* attribute in the output refers to the `StorageLocation`</Info>
