aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/manual/csv-import.md
blob: 6759e54e3ca579c39811be6cbf6a24cb037ee1c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# CSV Import

Kioku allows you to bulk import notes from CSV files.

## Basic Usage

1. Open the deck detail page and click the "Import" button
2. Select a CSV file
3. Review the import preview
4. Click "Import" to execute

## CSV Format

### Header Row

The first row is the header. Use the following format:

```
deck,note_type,Field1,Field2,...
```

- **deck**: Deck name (for reference only; import destination is selected in the UI)
- **note_type**: Note type name (required)
- **Field names**: Field names defined in the note type

### Data Rows

Rows 2 and onwards contain the notes to import.

```csv
deck,note_type,Front,Back
MyDeck,Basic,hello,world
MyDeck,Basic,goodbye,farewell
```

### Example: Basic Note Type

```csv
deck,note_type,Front,Back
Vocabulary,Basic,apple,a round fruit
Vocabulary,Basic,banana,a yellow fruit
Vocabulary,Basic,orange,a citrus fruit
```

### Example: Basic (and reversed card) Note Type

```csv
deck,note_type,Front,Back
Capitals,Basic (and reversed card),Tokyo,Japan
Capitals,Basic (and reversed card),Paris,France
Capitals,Basic (and reversed card),London,United Kingdom
```

## CSV Specification

Kioku's CSV parser is RFC 4180 compliant.

### Supported Format

- **Delimiter**: Comma (`,`)
- **Line endings**: LF (`\n`) or CRLF (`\r\n`)
- **Encoding**: UTF-8

### Quoting

Use double quotes (`"`) to include commas or newlines within a field:

```csv
deck,note_type,Front,Back
MyDeck,Basic,"Hello, World!",example with comma
MyDeck,Basic,"Line 1
Line 2",example with newline
```

To include a double quote within a field, escape it by doubling:

```csv
deck,note_type,Front,Back
MyDeck,Basic,"He said ""Hello""",example with quotes
```

## Important Notes

### Note Type Names

- Note type names are case-insensitive
- Note types must be created beforehand
- Rows with non-existent note types are skipped

### Field Names

- Field names are case-insensitive
- Rows with unrecognized field names are skipped
- All fields defined in the note type must be present in the CSV

### Validation

Validation runs before import. Rows with the following errors are skipped:

- Note type not found
- Field name mismatch
- Column count doesn't match the header

You can review errors in the preview screen.

## Troubleshooting

### "Note type 'XXX' not found" Error

The specified note type doesn't exist. Create the note type on the Note Types page first.

### "Field 'XXX' not found in note type" Error

The CSV field name doesn't match any field in the note type. Check the field names in your note type definition.

### "Expected N columns, got M" Error

The number of columns in a data row doesn't match the header. Check for missing or extra commas. If a field contains commas, wrap the value in double quotes.

### Character Encoding Issues

Save your CSV file as UTF-8. If using Excel, choose "CSV UTF-8" format when saving.