Reads .txt, .md, .docx and .pdf files, normalizes them to UTF-8 and
stores the text permanently in the sources table (frozen_text). The
original file is copied unchanged into originals/ next to the project
file. Files whose content hash was already imported are skipped, so text is
extracted exactly once per file.
Usage
qda_import(
files,
copy_originals = TRUE,
names = NULL,
segments = c("blankline", "speaker", "line"),
pseudonyms = NULL
)Arguments
- files
Character vector of file paths.
- copy_originals
Logical; copy the original files into
originals/.- names
Optional character vector of display names (one per file) – e.g. the original file names when importing uploads whose temp paths are meaningless (
0.pdf, ...). Defaults tobasename(files).- segments
How the new documents are divided into segments:
"blankline"(paragraphs, default),"speaker"(one segment per speaker turn, e.g."[00:01:12] P: ...") or"line". Can be changed later withqda_segments_set(); see alsoqda_segment_split().- pseudonyms
Optional key list for pseudonymisation (see
qda_pseudonyms()): names of people, places, organisations ... are replaced in the text – and in the document name – BEFORE the text is frozen. The key list itself is not stored in the project, and the original files are not copied tooriginals/(they contain the real names). Check the list first withqda_pseudonymise_preview().
Details
A different file with a name that is already taken (e.g.
a/interview.txt and b/interview.txt) is imported under a unique name
such as interview (2).txt, so no original is ever overwritten and every
source can still be addressed by its name.
PDFs without a usable text layer are imported with a warning (the original remains the source of truth; consider manual OCR, e.g. tesseract).
Examples
qda_open(file.path(tempfile(), "example.jellyqda"))
files <- system.file("extdata", c("interview_01.txt", "interview_02.md", "interview_03.docx"),
package = "jellyqda")
qda_import(files)
#> # A tibble: 3 × 5
#> id name format chars status
#> <int> <chr> <chr> <int> <chr>
#> 1 1 interview_01.txt txt 856 ok
#> 2 2 interview_02.md md 531 ok
#> 3 3 interview_03.docx docx 459 ok
qda_import(system.file("extdata", "fieldnotes.pdf", package = "jellyqda"),
segments = "line") # one segment per line
#> # A tibble: 1 × 5
#> id name format chars status
#> <int> <chr> <chr> <int> <chr>
#> 1 4 fieldnotes.pdf pdf 273 ok
qda_sources()
#> # A tibble: 4 × 7
#> id name format chars segments coded_chars imported_at
#> <int> <chr> <chr> <int> <int> <int> <chr>
#> 1 1 interview_01.txt txt 856 7 0 2026-11-30T15:06:01Z
#> 2 2 interview_02.md md 531 7 0 2026-11-30T15:06:01Z
#> 3 3 interview_03.docx docx 459 5 0 2026-11-30T15:06:02Z
#> 4 4 fieldnotes.pdf pdf 273 6 0 2026-11-30T15:06:02Z
f <- file.path(tempdir(), "interview_anna.txt")
writeLines(c("I: Anna, how did you start?", "Anna: In Hamburg, with Ben."), f)
qda_import(f, pseudonyms = c("Anna" = "[Person A]", "Hamburg" = "[City 1]", "Ben" = "[Person B]"))
#> Pseudonymised import: the original files are not copied to originals/ (they contain the real names).
#> # A tibble: 1 × 5
#> id name format chars status
#> <int> <chr> <chr> <int> <chr>
#> 1 5 interview_anna.txt txt 75 ok, pseudonymised (4 replacements)
qda_sources()$name[5] # the name is pseudonymised too
#> [1] "interview_anna.txt"
qda_close()