Created
February 26, 2013 09:48
-
-
Save mrdwab/5037343 to your computer and use it in GitHub Desktop.
Reads the sqlite database created by CintaNotes.
This file contains hidden or 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
print.cintanotes <- function(x, ...) { | |
for (i in 1:nrow(x)) { | |
cat("#", x[i, 2], "\n\n") | |
cat(paste("Posted on *", x[i, 4], "*\n\n", sep = "")) | |
cat(x[i, 3], "\n\n") | |
if (x[i, 5] != "") { | |
cat("Links: ", x[i, 5], "\n\n") | |
} | |
if (!is.na(x[i, 6])) { | |
cat("Tags: ", x[i, 6], "\n\n") | |
} | |
cat("--------------------------\n\n\n\n") | |
} | |
} |
This file contains hidden or 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
readCintaNotesDB <- function(DBLocation) { | |
require(sqldf) | |
GetTables <- paste("select * from", | |
c("NoteCache", "Notes", "NotesData_content", | |
"Notes_Tags", "Tags")) | |
TableNames <- c("metadata", "sources", "content", "tagindex", "tags") | |
output <- lapply(GetTables, function(x) sqldf(x, dbname = DBLocation)) | |
names(output) <- TableNames | |
output$metadata$created <- format(as.Date(output$metadata$created, | |
format = "%m/%d/%Y"), | |
"%d %B %Y") | |
T1 <- merge(merge(output[[1]], output[[2]], | |
by.x = "noteid", by.y = "id", all = TRUE), | |
output[[3]], by.x = "noteid", by.y = "docid", all = TRUE) | |
T2 <- merge(output[[4]], output[[5]], by.x = "tagid", by.y = "id", all = TRUE) | |
T2 <- aggregate(name ~ noteid, T2, paste, collapse = ", ") | |
output <- merge(T1, T2, all = TRUE) | |
output <- output[c(1, 9, 10, 2, 6, 11)] | |
names(output) <- c("noteid", "title", "text", "date", "references", "tags") | |
output$text <- gsub("\n", "\n\n", output$text) | |
class(output) <- c("cintanotes", class(output)) | |
output | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Load both functions, then use it something like:
To get a relatively cleaned-up version of your CintaNotes data that can be converted to a PDF using Pandoc.