Postgres로 CSV를 가져올 수 없습니다 (위치 4194303 위치에서 예기치 않은 문자)

StackOverflow https://stackoverflow.com//questions/25022965

문제

CSV를 내 redshift 데이터베이스로 가져 오려고하면이 오류가 발생합니다

Missing newline: Unexpected character 0x75 found at location 4194303                                
.

모든 것이 CSV 자체로 괜찮은 것 같습니다. STL 테이블은이 문자열이 포함 된 CSV의 70269 행에 오류가 오류가 있음을 알려줍니다.

10:00:10,2014-07-28,Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0),Not Listed,Not Listed,Not Listed,Not Listed,multiRetrieve,Not Listed,OS-Preview-logItemUsage,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,"[{""PubEndDate""=>""2013/12/31"", ""ItmId""=>""1353296053"", ""SourceType""=>""Scholarly Journals"", ""ReasonCode""=>""Free"", ""MyResearchUser""=>""246763"", ""ProjectCode""=>"""", ""PublicationCode""=>"""", ""PubStartDate""=>""2013/01/01"", ""ItmFrmt""=>""AbstractPreview"", ""Subrole""=>""AbstractPreview"", ""PaymentType""=>""Transactional"", ""UsageInfo""=>""P-1008275-154977-CUSTOMER-10000137-2950635"", ""Role""=>""AbstractPreview"", ""RetailPrice""=>0, ""EffectivePrice""=>0, ""ParentItemId""=>""53628""}]","[""optype:Online"", ""location:null"", ""target:null""]",192.234.111.8,DIALOG,20140728131712007:882391,1119643,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,"2014-07-28 10:00:10-0400,421 {""Items"":[{""PubEndDate"":""2013/12/31"",""ItmId"":""1353296053"",""SourceType"":""Scholarly Journals"",""ReasonCode"":""Free"",""MyResearchUser"":""246763"",""ProjectCode"":"""",""PublicationCode"":"""",""PubStartDate"":""2013/01/01"",""ItmFrmt"":""AbstractPreview"",""Subrole"":""AbstractPreview"",""PaymentType"":""Transactional"",""UsageInfo"":""P-1008275-154977-CUSTOMER-10000137-2950635"",""Role"":""AbstractPreview"",""RetailPrice"":0,""EffectivePrice"":0,""ParentItemId"":""53628""}],""Operation"":[""optype:Online"",""location:null"",""target:null""],""UserAgent"":""Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"",""UserInfo"":{""IP"":""192.234.111.8"",""AppId"":""DIALOG"",""SessId"":""20140728131712007:882391"",""UsageGroupId"":""1119643""},""UsageType"":""multiRetrieve"",""BreadCrumb"":""OS-Preview-logItemUsage""}
.

로드되지 않는 아이디어는 무엇입니까?

편집 : 숫자 '4194303'으로 명확하게해야합니다. 많은 RedShift 업로드 중 많은 부분이 실패했습니다. 여기에는 내 STL_LOAD_Errors의 간단한 샘플이 있습니다

Missing newline: Unexpected character 0x3a found at location 4194303                                
Missing newline: Unexpected character 0x63 found at location 4194303                                
Missing newline: Unexpected character 0x6c found at location 4194303                                
Missing newline: Unexpected character 0x22 found at location 4194303                                
.

이러한 오류가 'text'유형의 테이블의 모든 항목이 있고 약 30 개의 열이 있습니다. CSV 자체에는 수천 개의 레코드가 포함되어 있습니다 (상당한 CSV 파일).

해결 방법 (해결책이 아님)

숫자 4194303은 Redshift 복사의 truncatecolumns 기능으로 4MB 제한에서 설정한다는 것을 발견했습니다. 이 기능을 사용하지 않도록 설정하면 "문자열 길이가 DDL 길이를 초과"오류가 발생합니다 (첫 번째 위치에서 truncatecolumns를 사용하는 이유).

문제는 많은 기록이 4MB 이상이고 RedShift는 속성을 잘릴 필요가있는 경우 그러한 레코드를 지원하지 않는다는 것입니다.

그러나 복사 명령의 MaxError 1000 옵션을 사용하여 4MB + 레코드를 무시하고 4MB 미만인 행을 포함하는 데이터베이스로 왼쪽으로 왼쪽으로 둡니다.

도움이 되었습니까?

해결책

아래 옵션을 추가하여 복사 명령을 시도 할 수 있습니까?

acceptinvchars 탈출

Mac 또는 Windows에서 CSV 파일을 만들 때 일부 시간은 특수 문자가 포함될 수 있습니다.

다른 팁

문제는 EOL (줄 끝) 문자로입니다.나는 오늘 똑같은 문제가 있었고 문제는 내 CSV가 Mac EOL (아마 Cr)을 가지고 있다는 것이 었습니다.나는 그것을 유닉스 (LF를 사용하는)와 사본을 겪었습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top