gpt4 book ai didi

python - 表情符号在上传到 Bigquery 时崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 04:34:00 25 4
gpt4 key购买 nike

目前,我在将 EMOJI 数据上传(使用 python)到 BIG QUERY 时遇到问题

这是我要上传到 BQ 的示例代码:

 {"emojiCharts":{"emoji_icon":"\ud83d\udc4d","repost": 4, "doc": 4, "engagement": 0, "reach": 0, "impression": 0}} 
{"emojiCharts":{"emoji_icon":"\ud83d\udc49","repost": 4, "doc": 4, "engagement": 43, "reach": 722, "impression": 4816}}
{"emojiCharts":{"emoji_icon":"\u203c","repost": 4, "doc": 4, "engagement": 0, "reach": 0, "impression": 0}}
{"emojiCharts":{"emoji_icon":"\ud83c\udf89","repost": 5, "doc": 5, "engagement": 43, "reach": 829, "impression": 5529}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude34","repost": 5, "doc": 5, "engagement": 222, "reach": 420, "impression": 2805}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude31","repost": 3, "doc": 3, "engagement": 386, "reach": 2868, "impression": 19122}}
{"emojiCharts":{"emoji_icon":"\ud83d\udc4d\ud83c\udffb","repost": 5, "doc": 5, "engagement": 43, "reach": 1064, "impression": 7098}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude3b","repost": 3, "doc": 3, "engagement": 93, "reach": 192, "impression": 1283}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude2d","repost": 6, "doc": 6, "engagement": 212, "reach": 909, "impression": 6143}}
{"emojiCharts":{"emoji_icon":"\ud83e\udd84","repost": 8, "doc": 8, "engagement": 313, "reach": 402, "impression": 2681}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude18","repost": 7, "doc": 7, "engagement": 0, "reach": 8454, "impression": 56366}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude05","repost": 5, "doc": 5, "engagement": 74, "reach": 1582, "impression": 10550}}
{"emojiCharts":{"emoji_icon":"\ud83d\ude04","repost": 5, "doc": 5, "engagement": 73, "reach": 3329, "impression": 22206}}

问题是大查询看不到任何这种表情符号 (\ud83d\ude04),只会以这种格式显示 (\u203c)

即使该字段是STRING,它也显示 2 个黑色 rombs,为什么 BQ 不能将 emoji 显示为字符串而不将其转换为实际的 emoji?

问题:

有没有什么方法可以将 EMOJI 上传到 Big Query 并正确加载? - “将在 Google Data Studio 中使用

我是否应该手动(硬编码)将所有表情符号代码更改为可接受的代码,这是可接受的格式?

最佳答案

正如用户“numeral”在他们的评论中提到的:

Check out charbase.com/1f618-unicode-face-throwing-a-kiss What you want is to convert the javascript escape characters to actual unicode data.

,您需要更改表情符号的编码,以便将它们准确地表示为一个字符:

SELECT "\U0001f604 \U0001f4b8"
-- , "\ud83d\udcb8"
-- , "\ud83d\ude04"

第 2 行和第 3d 行失败并出现类似 Illegal escape sequence: Unicode value\ud83d is invalid at [2:7] 的错误,但第一行在 BigQuery 和 Data Studio 中给出了正确的显示:

enter image description here

enter image description here

关于此的其他想法:

关于python - 表情符号在上传到 Bigquery 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52169443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com