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
#### Entire workflow: | |
# Checked some of the data in jsonlint - corrected the errors → },{ instead of }{ between each line and [ and ] at the beginning and end of the file | |
# Made a smaller file to play with, containing about 11 JSON lines | |
# Used the code below to parse the datafile - however, checking the different listItems first if they are not lists themselves (that gives problems) // as you will see, | |
# I also removed things like \n because that gave errors and added an empty value for parent_id if there is none in the data (otherwise it would mix up the data) | |
# The code to import the .mongo file into R and then parse it into CSV: | |
setwd("/your/favourite/dir/json to csv/") |
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
# Credits for @cbdvs (Christopher Davis) - check out his amazing work here: http://enipedia.tudelft.nl or email him at: [email protected] | |
#never ever convert strings to factors | |
options(stringsAsFactors = FALSE) | |
###### TODO set this, the data will be written out there | |
setwd("/home/username/Desktop/R data/") | |
file.remove("allData.csv") ## removes the old datafile if there is one (so the data is not appended to the file, but a new file is created) |