Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. getwd()
  2. setwd("C:/Users/21357562/Desktop")
  3. getwd()
  4. Sys.setlocale("LC_ALL","pt_BR.UTF-8")
  5.  
  6. install.packages("jsonlite")
  7. library(jsonlite)
  8. reclamacao_2009 <- jsonlite::fromJSON(file.choose())
  9.  
  10.  
  11. #O comando readlines lê as linhas uma a uma
  12. #a variavel string é para direcionar o comando a ler tudo que é texto
  13. #paste serve para concatenar
  14. reclamacao_string <- paste(readLines("reclamacao_2009.json"), collapse = "")
  15. reclamacao_2009 <- jsonlite::fromJSON(reclamacao_string)
  16.  
  17.  
  18.  
  19. install.packages("RJSONIO")
  20. library(RJSONIO)
  21.  
  22. reclamacao_2009 <- RJSONIO::fromJSON(reclamacao_string)
  23.  
  24. reclamacao_2009_2<- RJSONIO::fromJSON("reclamacao_2009.json")
  25.  
  26.  
  27. install.packages("data.table")
  28. library(data.table)
  29.  
  30. dados_2009 <- rbindlist(l = reclamacao_2009_2, fill = TRUE)
  31.  
  32. rm(reclamacao_2009,reclamacao_2009_2, reclamacao_string)
  33.  
  34. dados_2009_limpos <- dados_2009[dados_2009$UF != "N/D",]
  35.  
  36.  
  37. sub_json<- jsonlite::toJSON(dados_2009_limpos)
  38.  
  39. write(sub_json, "reclamacao_2009_limpo.json")
  40. sub_json2 <- RJSONIO :: toJSON(dados_2009_limpos, pretty = TRUE)
  41. write(sub_json2, "reclamacao_2009_limpo_2.json")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement