# Import with debug output
opik import my-workspace experiment "my-experiment" --debug
```

## File Format

### JSON Format (Default)

The exported data is stored in JSON files with the following structure:

```
OUTPUT_DIR/
└── WORKSPACE/
    ├── datasets/
    │   ├── dataset_DATASET_NAME_1.json
    │   └── dataset_DATASET_NAME_2.json
    ├── projects/
    │   └── PROJECT_NAME/
    │       ├── trace_TRACE_ID_1.json
    │       └── trace_TRACE_ID_2.json
    ├── experiments/
    │   ├── experiment_EXPERIMENT_NAME_1.json
    │   └── experiment_EXPERIMENT_NAME_2.json
    └── prompts/
        ├── prompt_PROMPT_NAME_1.json
        └── prompt_PROMPT_NAME_2.json
```

Each trace file contains:

```json
{
  "trace": {
    "id": "trace-uuid",
    "name": "trace-name",
    "start_time": "2024-01-01T00:00:00Z",
    "end_time": "2024-01-01T00:01:00Z",
    "input": {...},
    "output": {...},
    "metadata": {...},
    "tags": [...],
    "thread_id": "thread-uuid"
  },
  "spans": [
    {
      "id": "span-uuid",
      "name": "span-name",
      "start_time": "2024-01-01T00:00:00Z",
      "end_time": "2024-01-01T00:01:00Z",
      "input": {...},
      "output": {...},
      "metadata": {...},
      "type": "general",
      "model": "gpt-4",
      "provider": "openai"
    }
  ],
  "downloaded_at": "2024-01-01T00:00:00Z",
  "project_name": "source-project"
}
```

Each evaluation rule file contains:

```json
{
  "id": "rule-uuid",
  "name": "rule-name",
  "project_id": "project-uuid",
  "project_name": "project-name",
  "sampling_rate": 1.0,
  "enabled": true,
  "filters": [...],
  "action": "evaluator",
  "type": "llm_as_judge",
  "created_at": "2024-01-01T00:00:00Z",
  "created_by": "user-id",
  "last_updated_at": "2024-01-01T00:00:00Z",
  "last_updated_by": "user-id",
  "evaluator_data": {
    "llm_as_judge_code": {
      "prompt": "Evaluate the response...",
      "model": "gpt-4",
      "temperature": 0.0
    }
  },
  "downloaded_at": "2024-01-01T00:00:00Z"
}
```

Each experiment file contains:

```json
{
  "experiment": {
    "id": "experiment-uuid",
    "name": "experiment-name",
    "dataset_name": "dataset-name",
    "type": "regular",
    "metadata": {...},
    "created_at": "2024-01-01T00:00:00Z"
  },
  "items": [
    {
      "trace_id": "trace-uuid",
      "dataset_item_id": "dataset-item-uuid",
      "dataset_item_data": {...},
      "feedback_scores": [...],
      "trace_reference": {
        "trace_id": "trace-uuid",
        "note": "Full trace data not included to avoid duplication"
      }
    }
  ],
  "downloaded_at": "2024-01-01T00:00:00Z"
}
```

Each prompt file contains:

```json
{
  "name": "prompt-name",
  "current_version": {
    "prompt": "Your prompt template here...",
    "metadata": {...},
    "type": "MUSTACHE",
    "commit": "commit-hash"
  },
  "history": [
    {
      "prompt": "Previous version of the prompt...",
      "metadata": {...},
      "type": "MUSTACHE",
      "commit": "previous-commit-hash"
    }
  ],
  "downloaded_at": "2024-01-01T00:00:00Z"
}
```

### CSV Format

When using `--format csv`, data is exported as CSV files with flattened data structure. This format is ideal for:

* **Data Analysis**: Easy to import into Excel, Google Sheets, or data analysis tools
* **Large Datasets**: More efficient storage for large numbers of traces
* **Spreadsheet Integration**: Direct compatibility with business intelligence tools

**CSV File Structure:**

```
OUTPUT_DIR/
└── WORKSPACE/
    ├── datasets/
    │   └── datasets_DATASET_NAME.csv      # Dataset data in CSV format
    ├── projects/
    │   └── PROJECT_NAME/
    │       └── traces_PROJECT_NAME.csv    # All traces in a single CSV file
    ├── experiments/
    │   └── experiments_EXPERIMENT_NAME.csv # Experiment data in CSV format
    └── prompts/
        └── prompts_PROMPT_NAME.csv        # Prompt data in CSV format
```

**CSV Format Benefits:**

* **Single File**: All data combined into one CSV file per data type
* **Flattened Structure**: Nested JSON data is flattened with dot notation
* **Column Headers**: Clear column names for easy analysis
* **Compatible**: Works with Excel, Google Sheets, pandas, etc.
* **Universal Format**: All data types (datasets, projects, experiments, prompts) support CSV export

**Example CSV Structure:**

```csv
trace_id,trace_name,start_time,end_time,thread_id,span_id,span_name,span_type,span_model,span_provider,input,output,metadata
trace-123,my-trace,2024-01-01T00:00:00Z,2024-01-01T00:01:00Z,thread-456,span-789,llm-call,llm,gpt-4,openai,"{""prompt"":""Hello""}","{""response"":""Hi""}","{""tokens"":10}"
```

## Use Cases

### 1. Project Migration

```bash