Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Reading a list
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cad Bilbao  
View profile  
 More options Nov 5 2001, 1:45 pm
Newsgroups: comp.lang.lisp
From: c...@bilbao.com (Cad Bilbao)
Date: 5 Nov 2001 10:45:33 -0800
Local: Mon, Nov 5 2001 1:45 pm
Subject: Reading a list
Hi!

I'm trying to read a list by using LISP. My list is a file that
resembles this:

----------//-------
1,John,Engineer
2,Peter,Director
3,Caroll,Engineer
...
-------------//-----

I read on the Internet that this kind of file is called a "comma
separated list". Could anybody help me to read these files?

I was searching the web, but I did not find any tip...

Thank you very much


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janis Dzerins  
View profile  
 More options Nov 5 2001, 2:15 pm
Newsgroups: comp.lang.lisp
From: Janis Dzerins <jo...@latnet.lv>
Date: 05 Nov 2001 21:05:07 +0200
Local: Mon, Nov 5 2001 2:05 pm
Subject: Re: Reading a list

c...@bilbao.com (Cad Bilbao) writes:
> Hi!

> I'm trying to read a list by using LISP.

How nice that you're trying. Could you also please tell us *how* are
you doing this?

>  My list is a file that resembles this:

> ----------//-------
> 1,John,Engineer
> 2,Peter,Director
> 3,Caroll,Engineer
> ...
> -------------//-----

> I read on the Internet that this kind of file is called a "comma
> separated list". Could anybody help me to read these files?

Well -- do *you* really need help in reading the file?

> I was searching the web, but I did not find any tip...

Oh how nice you told about what else you're doing.

> Thank you very much

Thank you for telling us about your deeds. And you know what -- you
are not alone! You are already a third person to ask this kind of
question recently. Try searching the web more carefully. I suggest
starting at http://groups.google.com.

--
Janis Dzerins

  Eat shit -- billions of flies can't be wrong.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Nov 5 2001, 2:18 pm
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@cs.nyu.edu>
Date: 05 Nov 2001 14:18:43 -0500
Local: Mon, Nov 5 2001 2:18 pm
Subject: Re: Reading a list

c...@bilbao.com (Cad Bilbao) writes:
> Hi!

> I'm trying to read a list by using LISP. My list is a file that
> resembles this:

> ----------//-------
> 1,John,Engineer
> 2,Peter,Director
> 3,Caroll,Engineer
> ...
> -------------//-----

> I read on the Internet that this kind of file is called a "comma
> separated list". Could anybody help me to read these files?

(defun almost-doing-your-homework (the-file)
   (with-open-file (f the-file :direction :input)
      (loop for line = (read-line f nil nil)
            while line
                do (print line))))

Cheers

--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Haugan  
View profile  
 More options Nov 6 2001, 4:40 am
Newsgroups: comp.lang.lisp
From: Erik Haugan <e...@haugan.no>
Date: Tue, 06 Nov 2001 09:39:37 GMT
Local: Tues, Nov 6 2001 4:39 am
Subject: Re: Reading a list
* c...@bilbao.com (Cad Bilbao)

> I'm trying to read a list by using LISP. My list is a file that
> resembles this:

> ----------//-------
> 1,John,Engineer
> 2,Peter,Director
> 3,Caroll,Engineer
> ...
> -------------//-----

> I read on the Internet that this kind of file is called a "comma
> separated list". Could anybody help me to read these files?

Shure.  Here's how:

1 learn some Lisp (start at www.lisp.org)
2 try to solve the problem yourself
3 if you still need help, post a message in this forum stating:
3.1 that you need help with your homework
3.2 the exact wording of the assignment
3.3 what you have tried so far
3.4 that you really like what you have learned about Lisp so far (for extra
    goodwill :-)

Good luck.

Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Symanzik  
View profile  
 More options Nov 8 2001, 4:43 pm
Newsgroups: comp.lang.lisp
From: Ed Symanzik <z...@msu.edu>
Date: Thu, 08 Nov 2001 16:43:14 -0500
Local: Thurs, Nov 8 2001 4:43 pm
Subject: Re: Reading a list
I've been trying a similar thing to read /etc/passwd.

  (setq passwd-readtable (copy-readtable))
  (set-syntax-from-char #\: #\space passwd-readtable))
  (loop for char in
     '(#\tab #\space #\" #\# #\' #\( #\) #\, #\; #\\ #\` #\|) do
     (set-syntax-from-char char #\A passwd-readtable))

  (setq orig-readtable (copy-readtable *readtable*))
  (copy-readtable passwd-readtable *readtable*)

  (setq in (open "/etc/passwd" :direction :input))

However, this is bad as the readtable applies to current
code.

Is there a way to apply a different readtable to a stream?

Or, as is likely the case, am I out in the weeds?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vebjorn Ljosa  
View profile  
 More options Nov 9 2001, 12:15 am
Newsgroups: comp.lang.lisp
From: Vebjorn Ljosa <ab...@ljosa.com>
Date: 08 Nov 2001 21:14:12 -0800
Local: Fri, Nov 9 2001 12:14 am
Subject: Re: Reading a list
* Ed Symanzik <z...@msu.edu>
| I've been trying a similar thing to read /etc/passwd.
|
|   (setq passwd-readtable (copy-readtable))
|   (set-syntax-from-char #\: #\space passwd-readtable))
|   (loop for char in
|      '(#\tab #\space #\" #\# #\' #\( #\) #\, #\; #\\ #\` #\|) do
|      (set-syntax-from-char char #\A passwd-readtable))
|
|   (setq orig-readtable (copy-readtable *readtable*))
|   (copy-readtable passwd-readtable *readtable*)
|
|   (setq in (open "/etc/passwd" :direction :input))
|
|
| However, this is bad as the readtable applies to current
| code.
|
| Is there a way to apply a different readtable to a stream?

You need to make sure that only stuff from the password file is being
read with *readtable* is bound to your customized readtable.  This
works:

(defvar *passwd-readtable* (copy-readtable))

(set-syntax-from-char #\: #\space *passwd-readtable*)

(loop
    for char in
      '(#\tab #\space #\" #\# #\' #\( #\) #\, #\; #\\ #\` #\|)
    do
      (set-syntax-from-char char #\A *passwd-readtable*))

(setq in (let ((*readtable* *passwd-readtable*)
               (stream (open "/etc/passwd" :direction :input)))
           (read stream)))
=> root

--
Vebjorn Ljosa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vebjorn Ljosa  
View profile  
 More options Nov 9 2001, 12:21 am
Newsgroups: comp.lang.lisp
From: Vebjorn Ljosa <ab...@ljosa.com>
Date: 08 Nov 2001 21:20:53 -0800
Local: Fri, Nov 9 2001 12:20 am
Subject: Re: Reading a list
* Ed Symanzik <z...@msu.edu>
| I've been trying a similar thing to read /etc/passwd.
|
|   (setq passwd-readtable (copy-readtable))
|   (set-syntax-from-char #\: #\space passwd-readtable))
|   (loop for char in
|      '(#\tab #\space #\" #\# #\' #\( #\) #\, #\; #\\ #\` #\|) do
|      (set-syntax-from-char char #\A passwd-readtable))
|
|   (setq orig-readtable (copy-readtable *readtable*))
|   (copy-readtable passwd-readtable *readtable*)
|
|   (setq in (open "/etc/passwd" :direction :input))
|
|
| However, this is bad as the readtable applies to current
| code.
|
| Is there a way to apply a different readtable to a stream?

You need to make sure that only stuff from the password file is being
read with *readtable* bound to your customized readtable.  This works:

(defvar *passwd-readtable* (copy-readtable))

(set-syntax-from-char #\: #\space *passwd-readtable*)

(loop
    for char in
      '(#\tab #\space #\" #\# #\' #\( #\) #\, #\; #\\ #\` #\|)
    do
      (set-syntax-from-char char #\A *passwd-readtable*))

(setq in (let ((*readtable* *passwd-readtable*)
               (stream (open "/etc/passwd" :direction :input)))
           (read stream)))
=> root

--
Vebjorn Ljosa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 9 2001, 6:07 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Fri, 09 Nov 2001 11:07:49 GMT
Local: Fri, Nov 9 2001 6:07 am
Subject: Re: Reading a list
* Ed Symanzik <z...@msu.edu>
| Is there a way to apply a different readtable to a stream?

  Have you tried a binding *readtable* across the relevant operations?

///
--
  Norway is now run by a priest from the fundamentalist Christian People's
  Party, the fifth largest party representing one eighth of the electorate.
--
  Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Symanzik  
View profile  
 More options Nov 13 2001, 3:23 pm
Newsgroups: comp.lang.lisp
From: Ed Symanzik <z...@msu.edu>
Date: Tue, 13 Nov 2001 15:19:05 -0500
Local: Tues, Nov 13 2001 3:19 pm
Subject: Re: Reading a list

Ed Symanzik wrote:

> I've been trying a similar thing to read /etc/passwd.

>   (setq passwd-readtable (copy-readtable))
>   (set-syntax-from-char #\: #\space passwd-readtable))
>   (loop for char in
>      '(#\tab #\space #\" #\# #\' #\( #\) #\, #\; #\\ #\` #\|) do
>      (set-syntax-from-char char #\A passwd-readtable))

>   (setq orig-readtable (copy-readtable *readtable*))
>   (copy-readtable passwd-readtable *readtable*)

>   (setq in (open "/etc/passwd" :direction :input))

Thanks for everyone's responses.  I was thinking it would
be a handy thing to let Lisp reader handle the parsing,
specially for comma separated values with optional
quotes.  This was working quite nicely until I realised
that strings are read as symbols and uppercased.  Not
good for usernames and pathnames.  Back to writing my
own parser.

Thanks again.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martti Halminen  
View profile  
 More options Nov 13 2001, 6:12 pm
Newsgroups: comp.lang.lisp
From: Martti Halminen <martti.halmi...@kolumbus.fi>
Date: Wed, 14 Nov 2001 01:02:58 +0200
Local: Tues, Nov 13 2001 6:02 pm
Subject: Re: Reading a list

Ed Symanzik wrote:

> Thanks for everyone's responses.  I was thinking it would
> be a handy thing to let Lisp reader handle the parsing,
> specially for comma separated values with optional
> quotes.  This was working quite nicely until I realised
> that strings are read as symbols and uppercased.  Not
> good for usernames and pathnames.  Back to writing my
> own parser.

Did you read Hyperspec section 23.1.2 ?

www.xanalys.com/software_tools/reference/HyperSpec/Body/sec_23-1-2-1....

--


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Symanzik  
View profile  
 More options Nov 14 2001, 8:35 am
Newsgroups: comp.lang.lisp
From: Ed Symanzik <z...@msu.edu>
Date: Wed, 14 Nov 2001 08:18:59 -0500
Local: Wed, Nov 14 2001 8:18 am
Subject: Re: Reading a list

Martti Halminen wrote:
> Did you read Hyperspec section 23.1.2 ?

> www.xanalys.com/software_tools/reference/HyperSpec/Body/sec_23-1-2-1....

Thanks.  I missed that.

Now, what happens if changes their gecos to something like
(+ 2 3) ?  Lisp will be fine with that as a symbol name, right?

What about a gecos of *readtable* ?  Will that get me in trouble?

Is there anything that makes this a poor method of parsing files?
Technically?  Style?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Nov 14 2001, 11:45 am
Newsgroups: comp.lang.lisp
From: tfb+goo...@tfeb.org (Tim Bradshaw)
Date: 14 Nov 2001 08:45:23 -0800
Local: Wed, Nov 14 2001 11:45 am
Subject: Re: Reading a list

> This was working quite nicely until I realised
> that strings are read as symbols and uppercased.  Not
> good for usernames and pathnames.  Back to writing my
> own parser.

Look at READTABLE-CASE. (but if you're reading passwd files you
probably want your own reader anyway).

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian P Templeton  
View profile  
 More options Nov 24 2001, 9:36 pm
Newsgroups: comp.lang.lisp
From: Brian P Templeton <b...@tunes.org>
Date: Sun, 25 Nov 2001 02:36:03 GMT
Local: Sat, Nov 24 2001 9:36 pm
Subject: Re: Reading a list

Ed Symanzik <z...@msu.edu> writes:
> Now, what happens if changes their gecos to something like
> (+ 2 3) ?  Lisp will be fine with that as a symbol name, right?

Yes.

--
BPT <b...@tunes.org>                  /"\ ASCII Ribbon Campaign
backronym for Linux:                    \ / No HTML or RTF in mail
        Linux Is Not Unix                        X  No MS-Word in mail
Meme plague ;)   --------->          / \ Respect Open Standards


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »