Dataport Import

roshiniroshini Member Posts: 122
Hi Experts!

While import file through dataport, I would like to import only lines starting with 7, remaining all lines, I want to skip.

Is there any function available for dataport.skip ??

Answers

  • SavatageSavatage Member Posts: 7,142
    sure you can do that.

    I don't know what your data looks like or what table you're trying to populate - but if you import your data into variables you can use
    Testfield := copystr("first field",1,1);
    if testfield = 7 then begin
    map your variables to nav fields
    end else begin
    currdataport.skip;
    end;
  • roshiniroshini Member Posts: 122
    Hi Savatage,

    Thank you for your reply.

    Sorry, I could n't explain properly. As I have .CSV file, having data. All character and Numeric.

    I need to import only starting lines with 7.

    in my data file, other lines starts with 1 or 2 and other numbers. But import only line starting with 7.

    before insert only, I would like to check, and insert only line starting with 7.
    as other lines having more numeric data, so I am getting errors.

    here I need to read the data file, before insert.
  • SavatageSavatage Member Posts: 7,142
    As I said - Create variables as substitues for the fields you want to import your data to.

    if the fields you want to import are called
    CODE
    NO
    ZIP
    then for example - create
    importedCODE
    importedNO
    ImportedZIP
    FieldCheck

    enter these variables into your dataport fields not the real nav fields.

    Onafterimport trigger
    fieldcheck := copystr("importedCode",1,1);
    if fieldcheck = '7' then begin
      validate(code,importedcode); 
      validate(no,importedno);
      validate(zip,importedzip);
    end else begin
      currdataport.skip;
    end;
    

    if you import into variable nothing gets put into your nav table until you map it to its corresponding nav field. good luck!

    you could always open your file in excel - sort it & delete all the lines that don't start with 7 & then save it back to csv - but that's no fun!
  • roshiniroshini Member Posts: 122
    Hi Savatage,

    Thanks a lot for detailed explanation.

    Great!!
Sign In or Register to comment.