Giter VIP home page Giter VIP logo

arkdb's Introduction

Travis build status Coverage status AppVeyor Build Status CRAN_Status_Badge lifecycle

arkdb

The goal of arkdb is to provide a convienent way to move data from large compressed text files (tsv, csv, etc) into any DBI-compliant database connection (e.g. MYSQL, Postgres, SQLite; see DBI), and move tables out of such databases into text files. The key feature of arkdb is that files are moved between databases and text files in chunks of a fixed size, allowing the package functions to work with tables that would be much to large to read into memory all at once.

Links

Installation

You can install arkdb from GitHub with:

# install.packages("devtools")
devtools::install_github("cboettig/arkdb")

Basic use

library(arkdb)

# additional libraries just for this demo
library(dbplyr)
library(dplyr)
library(fs)

Creating an archive of a database

Consider the nycflights database in SQLite:

db <- dbplyr::nycflights13_sqlite(".")
#> Caching nycflights db at ./nycflights13.sqlite
#> Creating table: airlines
#> Creating table: airports
#> Creating table: flights
#> Creating table: planes
#> Creating table: weather

Create an archive of the database:

ark(db, ".", lines = 50000)
#> Exporting airlines in 50000 line chunks:
#>  ...Done! (in 0.02494812 secs)
#> Exporting airports in 50000 line chunks:
#>  ...Done! (in 0.03492808 secs)
#> Exporting flights in 50000 line chunks:
#>  ...Done! (in 11.74483 secs)
#> Exporting planes in 50000 line chunks:
#>  ...Done! (in 0.03923202 secs)
#> Exporting weather in 50000 line chunks:
#>  ...Done! (in 0.8512921 secs)

Unarchive

Import a list of compressed tabular files (i.e. *.tsv.bz2) into a local SQLite database:

files <- fs::dir_ls(glob = "*.csv.bz2")
new_db <- src_sqlite("local.sqlite", create=TRUE)

unark(files, new_db, lines = 50000)
#> Warning in assert_files_exist(files): no file specified

new_db
#> src:  sqlite 3.22.0 [local.sqlite]
#> tbls:

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

ropensci_footer

arkdb's People

Contributors

cboettig avatar noamross avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.