Last active
August 29, 2015 14:16
-
-
Save patperu/4f92213f39877b900b90 to your computer and use it in GitHub Desktop.
New version of 'sofa'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################### | |
# | |
# Export data to a local CouchDB | |
# | |
############################################################### | |
library("RODBC") | |
#devtools::install_github("sckott/sofa") | |
library('sofa') # SHA: e9808c48e3ad40 | |
options(stringsAsFactors = FALSE) | |
lsort <- function(x) { lapply(strsplit(x, ";"), sort) } | |
# RODBC works only with 32-bit | |
channel <- odbcConnectExcel2007("./data/projectsfp7.xlsx") | |
x <- sqlFetch(channel, "cc0ce47364b29d1652b4789ec4e7f94", as.is = TRUE) | |
close(channel) | |
x <- x[1:15, ] | |
x$participants <- lsort(x$participants) | |
x$participantCountries <- lsort(x$participantCountries) | |
x$subjects <- lsort(x$subjects) | |
# local CouchDB running? | |
ping() | |
db_list() | |
db_create(dbname = 'fp7_rows') | |
doc_create(x, dbname = 'fp7_rows', how = "rows") | |
# ok | |
db_create(dbname = 'fp7_cols') | |
doc_create(x, dbname = 'fp7_cols', how = "columns") | |
# ok | |
# bulk | |
db_create(dbname = 'fp7_bulk') | |
bulk_create(x, dbname="fp7_bulk") | |
# ERROR | |
# Error: (500) - function_clause | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment