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

PaLPiTaTioN
Member Posts: 55
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:
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?
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?
0
Comments
-
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.0 -
You can try the following on the PreDataItem
currfile.textmode(true);
currfile.read(textvarof250charlength);
Cheers,
Gus0 -
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.0 -
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 railgun0 -
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:)0 -
doh!:)
That'll teach me to skim the text. Glad it worked at least.
Great minds think alike? heheheThad Ryker
I traded my sanity for a railgun0 -
hehe never mind :whistle:0
-
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.
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."0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions