Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access a text file in a given line??

9 views
Skip to first unread message

Enrique

unread,
Nov 1, 2002, 5:51:26 PM11/1/02
to
Is there a LISP function I can use to access a text file directly
to a given line? in other words, is there a function that allows to
access a file not as a stream, something like seek() in C???

Thank you,

ENrique

Nils Goesche

unread,
Nov 1, 2002, 6:05:27 PM11/1/02
to
fr...@cs.nyu.edu (Enrique) writes:

I am not sure how you can jump directly to a given line with
fseek() in C. I think you can't. But lookup FILE-POSITION in
the HyperSpec.

Regards,
--
Nils Goesche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0

Henrik Motakef

unread,
Nov 1, 2002, 6:23:58 PM11/1/02
to
fr...@cs.nyu.edu (Enrique) writes:

file-position would be something like seek, I guess. But of course,
both don't deal with lines. What do you want to do, exactly?

Regards
Henrik

Erik Naggum

unread,
Nov 1, 2002, 6:10:50 PM11/1/02
to
* fr...@cs.nyu.edu (Enrique)

| Is there a LISP function I can use to access a text file directly to a
| given line? in other words, is there a function that allows to access a
| file not as a stream, something like seek() in C???

Please see the standard function `file-position´ in the specification.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.

Marc Spitzer

unread,
Nov 1, 2002, 11:42:12 PM11/1/02
to
Nils Goesche <n...@cartan.de> wrote in news:87iszgs...@darkstar.cartan:

> fr...@cs.nyu.edu (Enrique) writes:
>
>> Is there a LISP function I can use to access a text file
>> directly to a given line? in other words, is there a function
>> that allows to access a file not as a stream, something like
>> seek() in C???
>
> I am not sure how you can jump directly to a given line with
> fseek() in C. I think you can't. But lookup FILE-POSITION in
> the HyperSpec.
>
> Regards,


I think he is talking about awk, you can not do that with fseek/C and the
fact that lines have varible size. How do you find the offset?

marc

Nils Goesche

unread,
Nov 2, 2002, 12:50:48 AM11/2/02
to
Marc Spitzer <mspi...@optonline.net> writes:

> Nils Goesche <n...@cartan.de> wrote in news:87iszgs...@darkstar.cartan:
>
> > fr...@cs.nyu.edu (Enrique) writes:
> >
> >> Is there a LISP function I can use to access a text file
> >> directly to a given line? in other words, is there a function
> >> that allows to access a file not as a stream, something like
> >> seek() in C???
> >
> > I am not sure how you can jump directly to a given line with
> > fseek() in C. I think you can't. But lookup FILE-POSITION in
> > the HyperSpec.
>

> I think he is talking about awk, you can not do that with
> fseek/C and the fact that lines have varible size. How do you
> find the offset?

That's what I thought, too, but we had so many touchy-feely
people here recently, that I wanted to avoid a ``How dare you
tell me it doesn't work? What if my lines are all of the same
length??´´ response ;-)

Regards,
--
Nils Gösche

Marc Spitzer

unread,
Nov 2, 2002, 1:27:11 AM11/2/02
to
Nils Goesche <n...@cartan.de> wrote in
news:87vg3ga...@darkstar.cartan:

> Marc Spitzer <mspi...@optonline.net> writes:
>
>> Nils Goesche <n...@cartan.de> wrote in
>> news:87iszgs...@darkstar.cartan:
>>
>> > fr...@cs.nyu.edu (Enrique) writes:
>> >
>> >> Is there a LISP function I can use to access a text file
>> >> directly to a given line? in other words, is there a function
>> >> that allows to access a file not as a stream, something like
>> >> seek() in C???
>> >
>> > I am not sure how you can jump directly to a given line with
>> > fseek() in C. I think you can't. But lookup FILE-POSITION in
>> > the HyperSpec.
>>
>> I think he is talking about awk, you can not do that with
>> fseek/C and the fact that lines have varible size. How do you
>> find the offset?
>
> That's what I thought, too, but we had so many touchy-feely
> people here recently, that I wanted to avoid a ``How dare you
> tell me it doesn't work? What if my lines are all of the same

> length??创 response ;-)
>
> Regards,

My personel oppinion is let the chips fall where they may. If I am wrong
or do something stupid I want to be corrected so I can stop doing it. If
having the fact that they did something stupid is a personel offence for
them, that is their problem.

I see CLL as a group of peers and peers in training and I *really* like
that. The quality of the discussions, both on and off topic, for the
most part is great. And this quality of discussion should be encouraged,
good standards should at the least be maintained.

Besides the defining charateristic in C of a line is a string that ends
when you get a '\n', That is how all the line oriented functions I
remember from C worked. I always refered to fixxed lenght things as
records not lines, so did the people around me, when talking C.

marc

Nils Goesche

unread,
Nov 2, 2002, 1:49:38 AM11/2/02
to
Marc Spitzer <mspi...@optonline.net> writes:

> Nils Goesche <n...@cartan.de> wrote in
> news:87vg3ga...@darkstar.cartan:
>
> > Marc Spitzer <mspi...@optonline.net> writes:
> >
> >> I think he is talking about awk, you can not do that with
> >> fseek/C and the fact that lines have varible size. How do
> >> you find the offset?
> >
> > That's what I thought, too, but we had so many touchy-feely
> > people here recently, that I wanted to avoid a ``How dare you
> > tell me it doesn't work? What if my lines are all of the

> > same length??´´ response ;-)


>
> My personel oppinion is let the chips fall where they may. If
> I am wrong or do something stupid I want to be corrected so I
> can stop doing it. If having the fact that they did something
> stupid is a personel offence for them, that is their problem.
>
> I see CLL as a group of peers and peers in training and I
> *really* like that. The quality of the discussions, both on
> and off topic, for the most part is great. And this quality of
> discussion should be encouraged, good standards should at the
> least be maintained.

Quite right. Sorry, I wasn't being entirely serious :)

> Besides the defining charateristic in C of a line is a string
> that ends when you get a '\n', That is how all the line
> oriented functions I remember from C worked.

Actually, that's how all the line oriented functions I remember
from Common Lisp work, too, like, say, READ-LINE :)

> I always refered to fixxed lenght things as records not lines,
> so did the people around me, when talking C.

Yes, I was joking. Sorry, again.

Marc Spitzer

unread,
Nov 2, 2002, 1:59:54 AM11/2/02
to
Nils Goesche <n...@cartan.de> wrote in
news:87lm4ca...@darkstar.cartan:

> Marc Spitzer <mspi...@optonline.net> writes:
>> I see CLL as a group of peers and peers in training and I
>> *really* like that. The quality of the discussions, both on
>> and off topic, for the most part is great. And this quality of
>> discussion should be encouraged, good standards should at the
>> least be maintained.
>
> Quite right. Sorry, I wasn't being entirely serious :)

No need to apoligize, it not your fault I am a bit too literal minded,
some people I know like to call it thick headed. Typeing messages back
and forth dose not help me, no tone of voice, body language etc.

>
>> Besides the defining charateristic in C of a line is a string
>> that ends when you get a '\n', That is how all the line
>> oriented functions I remember from C worked.
>
> Actually, that's how all the line oriented functions I remember
> from Common Lisp work, too, like, say, READ-LINE :)

Well a good idea is a good idea, but the implamentations sure do differ.

>
>> I always refered to fixxed lenght things as records not lines,
>> so did the people around me, when talking C.
>
> Yes, I was joking. Sorry, again.

No problem, no offence taken.

We all do the best we can and make do with what we have.

marc

>
> Regards,

0 new messages