still have to fix JSON validation errors

This commit is contained in:
2014-11-30 03:41:23 +01:00
parent c2190c7060
commit 0be709ff08
5 changed files with 566 additions and 237 deletions
+12 -2
View File
@@ -3,7 +3,17 @@ require(stringr)
# Replace characters messing up JSON validation (\,\n,^)
correctJSON <- function(string) {
string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ")
string <- str_replace_all(string, pattern = fixed("\n"), replacement = " ")
string <- str_replace_all(string, pattern = fixed("^"), replacement = " ")
string <- str_replace_all(string, pattern = "\n", replacement = " ")
string <- str_replace_all(string, pattern = "\r", replacement = " ")
string <- str_replace_all(string, pattern = "^", replacement = " ")
\xed\xa0\xbd\xed\xb1\x8d\xed\xa0\xbd\xed\xb8\x8e\
return(string)
}
insertRow <- function(existingDF, newrow, r) {
r <- as.numeric(nrow(existingDF)) + 1
existingDF <- rbind(existingDF,newrow)
existingDF <- existingDF[order(c(1:(nrow(existingDF)-1),r-0.5)),]
row.names(existingDF) <- 1:nrow(existingDF)
return(existingDF)
}