You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

How do I exclude the header row when reading in inbound file

3 replies [Last post]
Guest's picture
Guest

I have inbound csv file using filelayout but without the AE auto generated code. How do I skip the header row?

&INPUT = GetFile(&FILE_DIRECTORY | &FileName, "R", %FilePath_Absolute);
/*check if file is open*/
If &INPUT.IsOpen Then
If &INPUT.SetFileLayout(FileLayout.INBOUND_FL) Then
/*read line into &STRING*/
While &INPUT.ReadLine(&STRING);
&ARRAY = Split(&STRING, ",");
&i = 0;
For &i = 1 To &ARRAY.Len
&REC.GetField(&i).Value = RTrim(LTrim(&ARRAY [&i]));
End-For;
/* do additional processing here for converting values */
&REC.Insert();
/*count rows inserted into record*/
&COUNT = &COUNT + 1;
End-While;
Else
/* do error processing - filelayout not correct */
MessageBox(0, "", 0, 0, "File Layout is Invalid: ");
End-If;
Else
/* do error processing - file not open */
MessageBox(0, "", 0, 0, "File Not Open for processing: ");
End-If;
&INPUT.Close();

Lepa's picture
User offline. Last seen 13 weeks 3 days ago. Offline
Joined: 06/23/2008
Posts: 591
Re: How do I exclude the header row when reading in inbound file

I believe ReadLine starts from the top of your file and start reading row by row. So your code is almost there, if you don't want the header, then use the counter you have in your call to skip over the the processing and the insert part. You are incrementing the counter at the very end, so this skip will happen only once for the header.

/*read line into &STRING*/
While &INPUT.ReadLine(&STRING);
IF  &COUNT <> 0 THEN
  &ARRAY = Split(&STRING, ",");
  &i = 0;
  For &i = 1 To &ARRAY.Len
  &REC.GetField(&i).Value = RTrim(LTrim(&ARRAY [&i]));
  End-For;
  /* do additional processing here for converting values */
  &REC.Insert();
  /*count rows inserted into record*/
  &COUNT = &COUNT + 1;
END-IF;
End-While;

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Guest's picture
Guest (not verified)
Re: How do I exclude the header row when reading in inbound file

Great, got it thank you!

Lepa's picture
User offline. Last seen 13 weeks 3 days ago. Offline
Joined: 06/23/2008
Posts: 591
Re: How do I exclude the header row when reading in inbound file

Don't let PeopleSoft auto declare your counter. Make sure to declare it as a number and assign it a 0 at the top of your code before you start doing any processing.

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog