get.e
- Posted by don cole <doncole at pacbell.ne?> Jul 07, 2007
- 616 views
Matt Lewis wrote: > > don cole wrote: > > > > What I want to achieve is to read the whole file in one fell swoop. > > > > If I use gets() all the way through it works but takes longer. > > gets() is probably the fasted way to read it. get() is wholly inappropriate. > As the docs state, it's for reading euphoria objects that have been > printed using print (though is also handles things like double and single > quotes). You don't say how you plan to store the data, but I'll assume you > just want the lines concatenated: > > }}} <eucode> > object in > sequence s > s = {} > in = gets(fin) > while( sequence( in ) ) do > s &= in > in = gets( fin ) > end while > </eucode> {{{ > I use this basic pattern all the time for reading files (though I usually > keep each line in it's own sequence), and I've never had a problem with the > > speed. I recall one point in the past when people tried using things like > get_bytes to speed up file IO, but didn't. It seems that the actual > hardware IO is the bottleneck. > > Matt > }}} <eucode> object in sequence s integer fin fin=open("myfile.ew","r") s = {} in = gets(fin) while( sequence( in ) ) do s &= in in = gets( fin ) end while </eucode> {{{ Is what I'm using and you're saying that's faster than anything using get()? Don Cole