从BigQuery导入到R时的特殊字符 [英] Special characters when importing from BigQuery to R
本文介绍了从BigQuery导入到R时的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个脚本,用于剪贴一些推文并将结果保存到Google BigQuery.当我看到存储的数据时,special,➕️,Ñ,áéíóú之类的特殊字符会正确显示,但是当我尝试再次将数据导入R时,它们会被一些奇怪的字符替换.这是一个例子.
I have a script for scrapping some tweets and saving the results to Google BigQuery. When I see the stored data, special characters like ➕, ♂️, Ñ, áéíóú appear correctly, but when I try to import the data again to R they are replaced by some strange characters. Here's an example.
# Create df
id_tweet <- 1023985670224785408
tweet <- "◉ Neuroeducación y entornos digitales de aprendizaje: un paso obligado para educadores, pedagogos y psicólogos"
descripcion <- "Desde las alturas se ve todo de otra manera... ️ ➕ ♂️"
data <- data.frame(id, tweet, description)
# Save to Google BQ
library(bigrquery)
insert_upload_job("project-id", "dataset", "table", data , write_disposition = "WRITE_APPEND")
#Load from Gooble BQ
sql <- paste("SELECT *", "FROM", "`project-id.dataset.table`")
data <- query_exec(sql, project = "project-id", use_legacy_sql = FALSE)
我的输出如下:
> data
id_tweet
283 1023985670224785408
tweet
283 ◉ Neuroeducación y entornos digitales de aprendizaje: un paso obligado para educadores, pedagogos y psicólogos
descripcion
283 Desde las alturas se ve todo de otra manera... ï¿½ï¿½ï¸ âž• ��<U+200D>â™‚ï¸ ï¿½ï¿½ ��
我想要保留原始格式.
我该怎么办?
谢谢
推荐答案
6个月后,我终于设法解决了这个问题.我没有使用功能query_exec
,而是使用同一包中的bq_table_download
.此功能解决了这个问题.
After 6 months, I finally managed to solve this problem. Instead of using the function query_exec
i used bq_table_download
from the same package instead. This function solves the problem.
这篇关于从BigQuery导入到R时的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文