Examples for 'iotools::idstrsplit'


Create an iterator for splitting binary or character input into a dataframe

Aliases: idstrsplit

Keywords: iterator

### ** Examples

col_names <- names(iris)
write.csv(iris, file="iris.csv", row.names=FALSE)
it <- idstrsplit("iris.csv", col_types=c(rep("numeric", 4), "character"),
                 sep=",")
# Get the elements
iris_read <- it$nextElem()[-1,]
# or with the iterators package
# nextElem(it)
names(iris_read) <- col_names
print(head(iris_read))
  Sepal.Length Sepal.Width Petal.Length Petal.Width  Species
2          5.1         3.5          1.4         0.2 "setosa"
3          4.9         3.0          1.4         0.2 "setosa"
4          4.7         3.2          1.3         0.2 "setosa"
5          4.6         3.1          1.5         0.2 "setosa"
6          5.0         3.6          1.4         0.2 "setosa"
7          5.4         3.9          1.7         0.4 "setosa"
## remove iterator, connections and files
rm("it")
gc(FALSE)
          used (Mb) gc trigger (Mb) max used (Mb)
Ncells  643298 34.4    1099998 58.8  1099998 58.8
Vcells 5445035 41.6   10146329 77.5  5588815 42.7
unlink("iris.csv")

[Package iotools version 0.3-5 Index]