Re: HELP with 'seek'-- to Irv Mullins

new topic     » topic index » view thread      » older message » newer message

Irv,

Thanks for the suggestion, and for taking the time to include the
interesting code. I'll be studying it over the weekend.

Actually, the data does contains 100 bytes per line, 98 of text data, the \n
and, as Rob Craig pointed out, an additional (but invisible to gets() ), \r.

It looks like 86 characters because my e-mail composer messed it up
so badly.

Appreciate your help, Irv.

Regards,

Jim
Irv Mullins wrote:

> On Fri, 18 Aug 2000, you wrote:
> > Jim writes:
> > > I'm having a problem in using the 'seek' function...
> > > ...DataFile = open(fullpath,"r") -- open for reading
> >
>
> In addition, it may be easier to use get() to read these lines in.  This will
> allow for format variations and eliminate the need to cast strings into
> values.
> Depending upon how many lines are in the actual data you're working with,
> it would probably be much easier to just load them all into a sequence, and
> work with them there.
> See code below.
> Beyond that, I note that (1) the sample data only contains 86 characters plus
> a
> line feed (except for the last line)  no 99 that your code is looking for.
> Maybe your e-mail client (or mine) clipped the lines?
>
> Regards,
> Irv
>
> include get.e
>
> constant DATE = 1, OPEN1 = 2, HIGH1 = 3, LOW1 = 4,
>          CLOSE1 = 5, VOLUME1 = 6, OPENINT1 = 7
>
> object data, line
> atom fn
>
> function readline()
> object line, item
> line = {}
> for i = DATE to OPENINT1 do
>  item = get(fn)
>  if item[1] = GET_SUCCESS then
>     line = append(line,item[2])
>  else return -1
>  end if
> end for
> return line
> end function
>
> fn = open("testdata.txt","r")
> data = {}
> while 1 do
>    line = readline()
>    if atom(line) then exit
>    else data = append(data,line)
>    end if
> end while
> close(fn)
>
> printf(1,"%d records read\n",length(data))
>
> for i = 1 to length(data) do
>  printf(1,"Date: %s\n",{data[i][DATE]})
> end for

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu