0

나는 다음과 같은 형식의 파일을GAE bulkloader의 CSV 구분 기호 오류

이름 - stuffinside -description 이름 - stuffinside -description "ame- stuffinside -description

와 나는 같은 비트에 따라 한 내 bulkloader 코드 :

t는

ransformers: 
- kind: storeItem 
connector: csv 
connector_options: 
encoding: utf-8 
column_list: [name, stuffinside,description] 
property_map: 
- property: key 
external_name: name export_transform: transform.key_id_or_name_as_string 

- property: name 
    external_name: name 

- property: stuffinside 
    external_name: stuffinside 
    import_transform: "lambda x: x.split('-')" 

- property: description 
    external_name: description 

제가하는 데 문제는 내가 그것을 얻을 수 있다는 것입니다 파일을 "-"기호로 분리하고 3 개의 다른 부분으로 구성하십시오. 나는 내가 그 일을 아무 문제가없는 파일에서 읽기

name = x[0] 
stuffinside =x[1] 
description = x[2] 

처럼되고 싶어하지만, 나는이 응용 프로그램 엔진 벌크로드 형식을 어떻게 단서가 없다. 내가 뭘 잘못하고 있는지에 대한 아이디어가 있습니까?

답변

0

"-"는 필드 구분자로 사용할 좋은 기호입니까? 콘텐츠에 해당 기호가 포함되어있을 가능성이 매우 높습니다.

http://bulkloadersample.appspot.com/showfile/bulkloader.yaml에서 : 내 문제의

# A sample using a TSV file with no header, specifying the columns here. 
- model: models.Visit 
    connector: csv 
    connector_options: 
    encoding: windows-1252 
    # TSV is specified using an extra parameter of the Python csv module. 
    import_options: 
     dialect: excel-tab 
    export_options: 
     dialect: excel-tab 
    # Columns here are a sequence in YAML, so can be specified in either block 
    # or flow style. This is short enough that I'll use flow style. 
    column_list: [visitid, customer, date, score, activities] 
    property_map: 
    - property: __key__ 
     external_name: visitid 
     export_transform: datastore.Key.name 
    - property: customer 
     external_name: customer 
     import_transform: transform.create_foreign_key('Customer') 
     export_transform: datastore.Key.name 
    - property: visit_date 
     external_name: date 
     import_transform: transform.import_date_time('%m/%d/%Y') 
     export_transform: transform.export_date_time('%m/%d/%Y') 
    - property: score 
     external_name: score 
     import_transform: float 
    - property: activities 
     external_name: activities 
     # This is a CSV list of strings inside the TSV file. 
     import_transform: "lambda x: x.split(',')" 
     export_transform: "','.join" 
+0

아니라 부분은 텍스트의 일부 선적 지시 밖에 해줄 수 쉼표를 가지고 있다는 것입니다 "-"첫번째 탭 다음이 샘플을 따라

당신은 변환겠습니까. 그래서 다른 분리 문자로 나누고 싶습니다. 및 모든 콘텐츠를 수동으로 처리했습니다. 이상한 곳이 없습니다. 그것들을 넣은 장소에서만 그것입니다. name-stuffinside-description – user2202316

+0

name-stuffinside-description 새 줄과 그 형식이 반복됩니다. – user2202316