Page 1 of 1

Read text file from PC one line at a time

Posted: Thu May 15, 2008 9:23 am
by q4u
Hi,
Need something similar to a READ DATASET but for the PC...
Everything I've come across seems to read the whole file into an internal table at one go.

Thanks.

Re: Read text file from PC one line at a time

Posted: Thu May 15, 2008 9:37 am
by MattG
Why do you need read the file only one line at a time?

Re: Read text file from PC one line at a time

Posted: Thu May 15, 2008 10:30 am
by q4u
'cause i'm a sadist.. :twisted:

Re: Read text file from PC one line at a time

Posted: Thu May 15, 2008 3:47 pm
by MattG
You're trying to code this, so you must be a masochist :roll:

Re: Read text file from PC one line at a time

Posted: Thu May 15, 2008 3:59 pm
by q4u
So I'm getting the distinct impression that it's not possible then... :|

Re: Read text file from PC one line at a time

Posted: Fri May 16, 2008 2:48 am
by m@t
Read the file in one go, using the standard upload, then write it to the appserver. Then read it from the appserver a line at a time. Alternatively, use ftp, or other file transfer means, to get it to the appserver.

If you would explain WHY you want to read it a line at a time, you might get more help.

m@t

Re: Read text file from PC one line at a time

Posted: Fri May 16, 2008 2:52 am
by phillipm
Maybe the functional consultant wants it done that way.
...and functional consultant always knows best... :mrgreen:

Re: Read text file from PC one line at a time

Posted: Fri May 16, 2008 6:16 am
by Rich
Well.

Just defer the reading of the uploaded text till later.

Stick it all into a table and then Loop around (That's reading it one line at a time), or even use READ TABLE ..... INDEX and just keep incrementing the index. If said functional consultant asks if you are reading it one line at a time just point to the code and say with conviction 'YES'.

Re: Read text file from PC one line at a time

Posted: Fri May 16, 2008 8:18 am
by BradB
MattG wrote:You're trying to code this, so you must be a masochist :roll:
Here's how you turn sadistic - this will really hurt the person that asked for it :wink:

Code: Select all

DO.
* Call file open dialog
* Call file upload (to internal table)
* Delete all lines in the internal table except the one matching the index of the current DO loop
* If all lines deleted --> Exit
* Read internal table index 1 - move line to other internal table
ENDDO.

* Now process your other internal table

When you're asked why they have to process the file open dialog so many times, just say 'That's what you asked for' 8)

Re: Read text file from PC one line at a time

Posted: Fri May 16, 2008 12:47 pm
by m@t
phillipm wrote:Maybe the functional consultant wants it done that way.
...and functional consultant always knows best... :mrgreen:
No. The functional consultant is always a loony, who's best not let out on their own. Anyway, what self-respecting functional conslutant even knows what a line in a file is?

Re: Read text file from PC one line at a time

Posted: Tue May 20, 2008 9:31 am
by maen
A true functional consultant will notice it and say: "you're still reading the complete file in 1 go!"

Best to ask for seperate files with only 1 line in it. :twisted:

Re: Read text file from PC one line at a time

Posted: Tue May 20, 2008 10:34 am
by m@t
You could write some kind of OLE program to split the file into seperate lines, I suppose.

m@t

Re: Read text file from PC one line at a time

Posted: Tue May 20, 2008 10:53 am
by wilhitern1
If the file were an excel, you could read row 1 and then delete row 1. Or is that to obvious? I didn't see that you said what format the file was in.