Problem:you have a textfile with headers and you must import it with a dataport, but you want to skip the header line, because otherwise you get an error. How to do that?
Put some code in trigger "OnPreDataItem()":
(variable "cha" is CHAR)
IF CurrDataport.IMPORT THEN BEGIN
REPEAT
CurrFile.READ(cha);
UNTIL cha = 10; // of course in case the RecordSeparator is "<<NewLine>>"
END;
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
i dont want to hardocode the filepath but when the "user" slects the "csv"file from the options tab
iam using 4.0(SP3)
Thanks
GD
(variable "cha" is TYPE CHAR)
http://www.BiloBeauty.com
http://www.autismspeaks.org
GD
Is 10 the expected number of records?
A newline in a textfile is defined by 2 chars : CR/LF = Carriage Return + Line Feed = ASCII 13 + ASCII 10.
So I am reading char per char until I find ASCII value = 10. When I have found it, I know I am at the end-of-line.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I have used your code and it works perfectly, many thanks.
Thanks. :thumbsup:
\:D/
D365 Business Central Solutions Architect
BC AL/NAV C/AL Developer
BC Repositories.com
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Muthu