Bigqueryã®JSONãã¼ã¿ãRã§èªã¿è¾¼ãéã¯ndjsonã®stream_iné¢æ°ãå©ç¨ãã
Bigqueryã§åå¾ãããã¼ã¿ãæ´å½¢ãããã
Bigqueryã§å ¨ã¦å®çµãããªãããããããã¨ããããæéããªãã®ã§ããç¨åº¦BQã§ãã£ã¦ãã¨ã¯Rã§ãããã¨ã«ããã
ããããã¹ãããã¦ããã®ã§JSONã§ãããã¦ã³ãã¼ãã§ããªããã¨è¨ããã¦ãã¾ã£ãã
ãããJSONã§ãã¦ã³ãã¼ããã¦jsonliteããã±ã¼ã¸ã®ã§èªããã¨ããã以ä¸ã®ãããªã¨ã©ã¼ãåºãã
parse_con(txt, bigint_as_char) ã§ã¨ã©ã¼: parse error: trailing garbage
æ¤ç´¢ããã¨ä»¥ä¸ã®SOã«ãã©ãçãã
ã©ãããåè¡ã¯JSONã®ãã©ã¼ãããã«ãªã£ã¦ãããã®ã®åãªãã¸ã§ã¯ããJSONãã©ã¼ãããã«åã£ã¦ããªããããã
It turns out this is a "pseudo-JSON" file. I come across these in many naive API systems I work in. Each line is valid JSON, but the individual objects aren't in a JSON array.Â
ã¨ãããã¨ã§è¡åä½ã®å¦çãå¿ è¦ã¨ãªãã jsonliteããã±ã¼ã¸ã®å ´åãstream_iné¢æ°ãç¨ãããfileã§ã³ãã¯ã·ã§ã³ãä½ãã®ããã¤ã³ãã
data <- jsonlite::stream_in(file(path_data))
ãã®å ´åããã¹ãããããªãã¸ã§ã¯ãã¯ãã¹ããããã¾ã¾èªã¿è¾¼ã¾ããã
ãã¹ãããããªãã¸ã§ã¯ãããããªã«å±éãã¦ã»ããï¼flattenå¦çï¼å ´åã¯ndjsonããã±ã¼ã¸ã®stream_iné¢æ°ãè¯ãããã®å ´åãæ示çã«ã³ãã¯ã·ã§ã³ãä½ãå¿ è¦ã¯ãªãã
data <- ndjson::stream_in(path_data)
ãããã§ãããï¼