import_data: Import data from CSV or Excel files

View source: R/import_data.R

import_dataR Documentation

Import data from CSV or Excel files

Description

Reads a CSV (.csv) or 'Excel' (.xlsx, .xls) file and returns a data frame. Column names are converted to snake_case and duplicates are made unique.

Usage

import_data(filepath, sheet = 1, sep = ",", dec = ".", ...)

Arguments

filepath

Character string. Path to the data file. Supported formats: .csv, .xlsx, .xls.

sheet

Character or integer. For Excel files, the sheet to read. Defaults to the first sheet. Ignored for CSV files.

sep

Character. Field separator for CSV files. Default ",". Use ";" for European-style CSVs.

dec

Character. Decimal separator for CSV files. Default ".". Use "," for European-style CSVs.

...

Additional arguments passed to utils::read.csv() or readxl::read_excel().

Value

A data frame with column names converted to snake_case. Duplicate column names are made unique by appending numeric suffixes.

Examples

# Load the included demo appraisal dataset
demo_file <- system.file("extdata", "Appraisal_1.csv", package = "earthUI")
df <- import_data(demo_file)
head(df)

earthUI documentation built on March 26, 2026, 1:07 a.m.