Package 'impexpcsv'

Title: Import Various csv Files with Common Columns and Export in One csv file
Description: Import various csv files with common columns and export in one csv file. Csv files are imported with data.table::fread(), row-binded with data.table::rbindlist() and exported with data.table::fwrite().
Authors: Sandro Burri <[email protected]>
Maintainer: Sandro Burri <[email protected]>
License: GPL-2
Version: 0.0.6
Built: 2024-11-14 06:14:54 UTC
Source: https://github.com/SwissStatsR/impexpcsv

Help Index


Retrieves all column names from different csv files

Description

Retrieves all column names from different csv files

Usage

all_columns(csv_files, ...)

Arguments

csv_files

a character vector with paths to one ore more csv files

...

further arguments to be passed to data.table::fread() (except nrows, which is set to 0)

Examples

# The package contains two small csv files: csv01.csv and csv02.csv
# The first one has 3 columns: x, y and z
# The second one has only 2 columns: x and z
all_columns(
  c(system.file("extdata", "csv01.csv", package = "impexpcsv"),
  system.file("extdata", "csv02.csv", package = "impexpcsv"))  
)

Create a "row-binded" csv file appending common columns of various csv files

Description

Create a "row-binded" csv file appending common columns of various csv files

Usage

bind_csv(csv_files, col_names = NULL, csv_output, sep_output = ";", ...)

Arguments

csv_files

a character vector with paths to one ore more csv files

col_names

a character vector with the names of the columns to be imported from each csv file. If NULL (default), all common columns will be imported.

csv_output

path to the csv file to be created and saved

sep_output

column separator of csv_output (defalut: ";")

...

further arguments to be passed to data.table::fread() (except nrows, which is set to 0)

Value

a NULL value. A summary message is printed on the screen.

Examples

## Not run: 
csv_files <- c(
  system.file("extdata", "csv01.csv", package = "impexpcsv"),
  system.file("extdata", "csv02.csv", package = "impexpcsv")  
)

bind_csv(csv_files, csv_output = "big_csv.csv")
bind_csv(csv_files, col_names = "x", csv_output = "big_csv.csv")
bind_csv(csv_files, col_names = c("z", "x"), csv_output = "big_csv.csv")

## End(Not run)

Create a "row-binded" csv file appending all columns of various csv files

Description

Create a "row-binded" csv file appending all columns of various csv files

Usage

bind_csv_all(csv_files, col_names = NULL, csv_output, sep_output = ";", ...)

Arguments

csv_files

a character vector with paths to one ore more csv files

col_names

a character vector with the names of the columns to be imported from each csv file. If NULL (default), all common columns will be imported.

csv_output

path to the csv file to be created and saved

sep_output

column separator of csv_output (defalut: ";")

...

further arguments to be passed to data.table::fread() (except nrows, which is set to 0)


Find common columns of various csv files

Description

Find common columns of various csv files

Usage

common_columns(csv_files, ...)

Arguments

csv_files

a character vector with paths to one ore more csv files

...

further arguments to be passed to data.table::fread() (except nrows, which is set to 0)

Value

a character vector with the names of the common columns of the csv files

Examples

# The package contains two small csv files: csv01.csv and csv02.csv
# The first one has 3 columns: x, y and z
# The second one has only 2 columns: x and z
common_columns(
  c(system.file("extdata", "csv01.csv", package = "impexpcsv"),
  system.file("extdata", "csv02.csv", package = "impexpcsv"))  
)

Import various csv files in a "row-binded" data.table with the same columns

Description

Import various csv files in a "row-binded" data.table with the same columns

Usage

import_list_csv(csv_files, col_names = NULL, ...)

Arguments

csv_files

a character vector with paths to one ore more csv files

col_names

a character vector with the names of the columns to be imported from each csv file. If NULL (default), all common columns will be imported.

...

further arguments to be passed to data.table::fread() (except nrows, which is set to 0)

Value

a data table with all the csv files binded together

Examples

# The package contains two small csv files: csv01.csv and csv02.csv
# The first one has 3 columns: x, y and z
# The second one has only 2 columns: x and z

# By default, import_list_csv imports all the common columns of the csv 
# files
import_list_csv(
  c(system.file("extdata", "csv01.csv", package = "impexpcsv"),
  system.file("extdata", "csv02.csv", package = "impexpcsv"))  
)

# Import only column "x" of each csv file
import_list_csv(
  c(system.file("extdata", "csv01.csv", package = "impexpcsv"),
  system.file("extdata", "csv02.csv", package = "impexpcsv")),
  col_names = "x"
)