How do I skip the first line when importing with a dataport?

PaLPiTaTioNPaLPiTaTioN Member Posts: 55
edited 2004-12-16 in Navision Attain
I've written a dataport that should import a file with variable field length and a TAB as delimiter. The problem is that the file starts with a header that should not be imported. I tried to use a SKIP on both OnBeforeImportRecord and OnAfterImportRecord but it doesn't stop the error I get:
The text 'column_name' is too long. The test in de code fields can have a maximum length of 1 characters.

This error applies to a field with type Code and length 1. If I enlarge the length of the field, I get an error on another field saying I can't insert ascii in a decimal field. All due to the fact that the header line is imported, which should not happen at all.

Can anybody tell me how to skip the first line of the file that is being imported?

Comments

  • 2tje2tje Member Posts: 80
    Have you tried to add the DataItem Integer before the table you import to ?
    Filter for 1 record and read the data into a variable.
  • g_dreyerg_dreyer Member Posts: 123
    You can try the following on the PreDataItem

    currfile.textmode(true);
    currfile.read(textvarof250charlength);

    Cheers,
    Gus
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    g_dreyer wrote:
    You can try the following on the PreDataItem

    currfile.textmode(true);
    currfile.read(textvarof250charlength);

    Cheers,
    Gus

    Thank you. I made a textvar of 1024 chars length, because the first line now contains 777 characters and will contain some more in the near future.
    2tje wrote:
    Have you tried to add the DataItem Integer before the table you import to ?
    Filter for 1 record and read the data into a variable.

    Won't work, because there's no white line between the header and the first data line. If I try, the contents of the file is seen as integer-records, because the RecordSeparator is never found. The filter skips all file content from line 2, so only line 1 is read and that line is nog inserted.
  • DakkonDakkon Member Posts: 192
    Have you tried putting something like
    CurrFile.READ(Junk);
    
    in the OnBeforeImportRecord trigger? The variable named 'Junk' above should be a text 250 char or something.
    I haven't tested this, but it should cause the file object that the dataport uses to skip to the next line.
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    Dakkon wrote:
    Have you tried putting something like
    CurrFile.READ(Junk);
    
    in the OnBeforeImportRecord trigger? The variable named 'Junk' above should be a text 250 char or something.
    I haven't tested this, but it should cause the file object that the dataport uses to skip to the next line.

    which was already suggested earlier:
    g_dreyer wrote:
    You can try the following on the PreDataItem

    currfile.textmode(true);
    currfile.read(textvarof250charlength);

    Cheers,
    Gus

    Yes I did and it works O:)
  • DakkonDakkon Member Posts: 192
    doh!:)
    That'll teach me to skim the text. Glad it worked at least.
    Great minds think alike? hehehe
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    hehe never mind :whistle:
  • eromeineromein Member Posts: 589
    Have you tried to add the DataItem Integer before the table you import to ?
    Filter for 1 record and read the data into a variable.
    Won't work, because there's no white line between the header and the first data line. If I try, the contents of the file is seen as integer-records, because the RecordSeparator is never found. The filter skips all file content from line 2, so only line 1 is read and that line is nog inserted.

    I think this is the best solution! If you would open the dataport a year later you would see in seconds why the integer loop is there and what it should do! The best solution!

    The reason why it does not work is becaurse you'll need to set the "DataItemSeparator" property to "<NewLine>".
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
Sign In or Register to comment.