Not Reading the first line while importing

bobnavision
Member Posts: 159
Hi,
I am using a dataport to import CSV file. The first line of the CSV file is having heading which I do not want to import .
How can we ignore the first line so that dataport does not give any error while importing because of the headings?
Regards,
I am using a dataport to import CSV file. The first line of the CSV file is having heading which I do not want to import .
How can we ignore the first line so that dataport does not give any error while importing because of the headings?
Regards,
0
Comments
-
Two ways:
1. Remove the heading from the csv file and import
2. Use a variable iCount that increases in the OnAfterImportRecord. When the iCount = 1 (first line) do CurrDataport.SKIP;0 -
I cannot use the first way because it will on client site,
The second way I tried but it didn't worked. I declared an integer variable
wrote the code CurrDataport.skip on OnBeforeImport but it wont work.
It never reaches to the code.
rgds0 -
In the "OnPreDataItem()", put this code:
IF CurrDataport.IMPORT THEN BEGIN CurrFile.TEXTMODE(TRUE); CurrFile.READ(txt); CurrFile.TEXTMODE(false); END;
And txt is a text1024-variable.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
-
Just created a Tips&Tricks. This will also help if the headerline is more then 1024 chars: http://www.mibuso.com/forum/viewtopic.php?p=43344#43344Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
-
Hi Kriki,
That amazingly works. I appreciate that.
what is this code doing and how CHAR works.
How we will make it to work for 2 lines ?
Regards0 -
to run it for two lines, just add put the code twice
IF CurrDataport.IMPORT THEN BEGIN CurrFile.TEXTMODE(TRUE); CurrFile.READ(txt); CurrFile.READ(txt); CurrFile.TEXTMODE(false); END;
0 -
bobnavision wrote:Hi Kriki,
That amazingly works. I appreciate that.
what is this code doing and how CHAR works.
How we will make it to work for 2 lines ?
Regards
In DOS/Windows, each end of line is finished with a CR/LF (carriage return/line feed) in ascii 13/10. So If I find the 10, I know that next char is a char of line 2 and stop reading.
And for 2 lines, you can just put an extra repeat-until. Otherwise you can use a counter.I'll put this code in the tip&tricks.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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