Mette
Mette

Reputation: 325

How to prevent errors in format (string-variable) when downloading data from Google Big Query to R?

I have some data stored (Tweets streamed from Twitters Rest API) in Google Big Query, which, in the preview looks like this

'I’m up by myself.'

However, when I download it into R, it looks like this;

'I’m up by myself.'

Is there any way to prevent it?

I am using this code to download the data in R:


library(bigrquery)

 project_id <- "my_project"
 sql_string <- 
 "SELECT 
 text,
 FROM my_under_project.my_table,
 LIMIT 500
 ;"

test <- query_exec(sql_string, project = project_id, useLegacySql = FALSE, allowLargeResults=TRUE, max_pages = Inf)

str(test)
#data.frame':   500 obs. of  1 variable:
#$ text: chr  "tweets" ...

The data from 'text' is stored as a string in Big Query.

Any help is appreciated! Thanks in advance!

Upvotes: 0

Views: 81

Answers (1)

Mette
Mette

Reputation: 325

I downloaded the data by 'bq_table_download' from the same package (instead of query_exec) from the same package and that solved the problem!

Special characters when importing from BigQuery to R

Upvotes: 1

Related Questions