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 |
Retrieves all column names from different csv files
all_columns(csv_files, ...)
all_columns(csv_files, ...)
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) |
# 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")) )
# 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
bind_csv(csv_files, col_names = NULL, csv_output, sep_output = ";", ...)
bind_csv(csv_files, col_names = NULL, csv_output, sep_output = ";", ...)
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) |
a NULL value. A summary message is printed on the screen.
## 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)
## 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
bind_csv_all(csv_files, col_names = NULL, csv_output, sep_output = ";", ...)
bind_csv_all(csv_files, col_names = NULL, csv_output, sep_output = ";", ...)
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
common_columns(csv_files, ...)
common_columns(csv_files, ...)
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) |
a character vector with the names of the common columns of the csv files
# 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")) )
# 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
import_list_csv(csv_files, col_names = NULL, ...)
import_list_csv(csv_files, col_names = NULL, ...)
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) |
a data table with all the csv files binded together
# 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" )
# 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" )