【问题标题】:Loading CSV to Redshift: "Missing newline: Unexpected character found at location 2"将 CSV 加载到 Redshift:“缺少换行符:在位置 2 发现意外字符”
【发布时间】:2014-09-08 18:33:16
【问题描述】:

我正在尝试将 S3 中的 CSV 加载到 Redshift。数据如下所示:

tweet_id,tweet_text,created_at,geo_lat,geo_long,user_id,screen_name,name,profile_image_url,is_rt
477097990809612288,RT @Sourpatchcam: Matthew espinosa is the reason I breath,2014-06-12 10:39:59,.00000,.00000,969145484,PerfectJvcob,PerfectJvcob || Bio,http://pbs.twimg.com/profile_images/477092469893382146/k1YAOGRf_normal.jpeg,True
477097991049064448,@ajama3 @SultansThrone @itsfuad Dont hold your breath.,2014-06-12 10:39:59,.00000,.00000,719529744,MareejoXaamud,¯\_(ツ)_/¯,http://pbs.twimg.com/profile_images/471392213906104321/VbyMbZ7e_normal.jpeg,False

我收到此错误:

Missing newline: Unexpected character 0x74 found at location 2

(字符 0x74 是 t)。

我尝试删除标题行,但我得到了“4”的意外字符。我的源代码中需要 /n 吗?

【问题讨论】:

    标签: csv amazon-web-services amazon-redshift


    【解决方案1】:

    您应该删除标题,因为标题是字符串,而您的实际列可能是整数、日期小数等。

    尝试使用以下选项进行复制以避免特殊字符或转义等

    转义接受字符

    【讨论】:

      【解决方案2】:

      这显然也可能是由 NULL 字符引起的

      https://www.flydata.com/blog/handling-utf-8-characters-in-redshift/

      【讨论】:

        【解决方案3】:

        检查 FROM 中提到的路径中 CSV 文件的扩展名。理想情况下应该是 file_name**.CSV**

        它帮助我解决了问题。

        【讨论】:

          【解决方案4】:

          我的文件副本遇到了同样的问题,当我将文件从 Unicode 转换为 UTF-8 编码

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2014-09-21
            • 2018-01-23
            • 1970-01-01
            • 2022-01-20
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多