Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading CSV to Redshift: "Missing newline: Unexpected character found at location 2"

I'm trying to load a CSV in S3 onto Redshift. The data looks like this:

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

I get this error:

Missing newline: Unexpected character 0x74 found at location 2

(Character 0x74 is t).

I tried removing the header row and I just got the unexpected character for "4." Do I need a /n in my source or something?

like image 422
Michael Carper Avatar asked Jul 17 '14 18:07

Michael Carper


3 Answers

This can also be caused by NULL characters apparently

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

like image 146
rado Avatar answered Nov 07 '22 14:11

rado


You should remove the headers as headers are string and your actual columns might be integer, date decimal etc.

Try copy with below options to avoid special chars or escape etcs

ESCAPE ACCEPTINVCHARS

like image 38
Sandesh Deshmane Avatar answered Nov 07 '22 15:11

Sandesh Deshmane


Check the extension for the CSV file in the path mentioned in FROM. It should ideally be file_name**.CSV**

It helped me to resolve the problem.

like image 1
user8427491 Avatar answered Nov 07 '22 13:11

user8427491