File: quickReadCsv.Rd

package info (click to toggle)
r-bioc-alabaster.base 1.6.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,652 kB
  • sloc: cpp: 11,377; sh: 29; makefile: 2
file content (71 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/quickReadCsv.R
\name{quickReadCsv}
\alias{quickReadCsv}
\alias{.quickReadCsv}
\alias{.quickWriteCsv}
\alias{quickWriteCsv}
\title{Quickly read and write a CSV file}
\usage{
quickReadCsv(
  path,
  expected.columns,
  expected.nrows,
  compression,
  row.names,
  parallel = TRUE
)

quickWriteCsv(
  df,
  path,
  ...,
  row.names = FALSE,
  compression = "gzip",
  validate = TRUE
)
}
\arguments{
\item{path}{String containing a path to a CSV to read/write.}

\item{expected.columns}{Named character vector specifying the type of each column in the CSV (excluding the first column containing row names, if \code{row.names=TRUE}).}

\item{expected.nrows}{Integer scalar specifying the expected number of rows in the CSV.}

\item{compression}{String specifying the compression that was/will be used.
This should be either \code{"none"}, \code{"gzip"}.}

\item{row.names}{For \code{.quickReadCsv}, a logical scalar indicating whether the CSV contains row names. 

For \code{.quickWriteCsv}, a logical scalar indicating whether to save the row names of \code{df}.}

\item{parallel}{Whether reading and parsing should be performed concurrently.}

\item{df}{A \linkS4class{DataFrame} or data.frame object, containing only atomic columns.}

\item{...}{Further arguments to pass to \code{\link{write.csv}}.}

\item{validate}{Whether to double-check that the generated CSV complies with the comservatory specification.}
}
\value{
For \code{.quickReadCsv}, a \linkS4class{DataFrame} containing the contents of \code{path}.

For \code{.quickWriteCsv}, \code{df} is written to \code{path} and a \code{NULL} is invisibly returned.
}
\description{
Quickly read and write a CSV file, usually as a part of staging or loading a larger object.
This assumes that all files follow the \href{https://github.com/LTLA/comservatory}{comservatory} specification.
}
\examples{
library(S4Vectors)
df <- DataFrame(A=1, B="Aaron")

temp <- tempfile()
.quickWriteCsv(df, path=temp, row.names=FALSE, compression="gzip")

.quickReadCsv(temp, c(A="numeric", B="character"), 1, "gzip", FALSE)

}
\author{
Aaron Lun
}