% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read_surveys.R
\name{read_surveys}
\alias{read_surveys}
\alias{read_survey}
\title{Read survey files into memory or save as `.rds`}
\usage{
read_surveys(
  survey_paths,
  .f = NULL,
  export_path = NULL,
  ids = NULL,
  dois = NULL,
  ...
)

read_survey(
  file_path,
  .f = NULL,
  export_path = NULL,
  doi = NULL,
  id = NULL,
  ...
)
}
\arguments{
\item{survey_paths}{A character vector containing full or relative
paths to survey files.}

\item{.f}{Import function to use. When `NULL`, the appropriate
  import function is selected automatically from the file
  extension.

  Supported formats are:

  \describe{
    \item{`.sav`, `.por`}{[read_spss()]}
    \item{`.dta`}{[read_dta()]}
    \item{`.rds`}{[read_rds()]}
    \item{`.csv`}{[read_csv()]}
  }}

\item{export_path}{Optional path where imported surveys should
be saved as `.rds` files. Defaults to `NULL`.}

\item{ids}{Optional survey identifiers.}

\item{dois}{Optional DOI identifiers for the imported surveys.}

\item{...}{Additional arguments passed to the import function.}
}
\value{
If `export_path = NULL`, a list of imported survey objects.

If `export_path` is provided, a character vector containing
exported `.rds` file names.

Imported surveys are returned as data frame-like
[survey()] objects with metadata attributes retained for
reproducible workflows.
}
\description{
Import one or more survey files into R using a consistent survey
import workflow. The function supports SPSS (`.sav`, `.por`),
Stata (`.dta`), R (`.rds`), and CSV files.
}
\details{
Use [read_survey()] to import a single survey file and
`read_surveys()` to import multiple files in a loop.

When `export_path` is `NULL`, imported surveys are returned as
a list in memory. When `export_path` is a valid directory,
imported surveys are saved as `.rds` files with
[base::saveRDS()].

Files that cannot be imported are skipped gracefully. A message
is printed and `NULL` is returned for the affected file.
}
\examples{
file1 <- system.file(
  "examples",
  "ZA7576.rds",
  package = "retroharmonize"
)

file2 <- system.file(
  "examples",
  "ZA5913.rds",
  package = "retroharmonize"
)

surveys <- read_surveys(
  c(file1, file2),
  .f = "read_rds"
)

}
\seealso{
[read_survey()], [survey()]

Other import functions:
\code{\link[=harmonize_survey_variables]{harmonize_survey_variables()}},
\code{\link[=pull_survey]{pull_survey()}},
\code{\link[=read_csv]{read_csv()}},
\code{\link[=read_dta]{read_dta()}},
\code{\link[=read_rds]{read_rds()}},
\code{\link[=read_spss]{read_spss()}}
}
\concept{import functions}
\keyword{internal}
