Skip to content

Commit 0a2f833

Browse files
committed
Create json2tweets.R
1 parent c2ec48e commit 0a2f833

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
library(jsonlite)
2+
options(encoding = "UTF-8")
3+
4+
# read in individual JSON lines
5+
json_file <- "C:\\Users\\ujjwal.karn\\Desktop\\Tweets\\python.json"
6+
7+
# turn it into a proper array by separating each object with a "," and
8+
# wrapping that up in an array with "[]"'s.
9+
10+
dat <- fromJSON(sprintf("[%s]", paste(readLines(json_file), collapse=",")))
11+
12+
dim(dat)
13+
## [1] 3959 18
14+
15+
tweets<-dat$text
16+
tweets

0 commit comments

Comments
 (0)