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
Message from discussion LISP style question - (with-open-file)

Received: by 10.68.220.230 with SMTP id pz6mr9884697pbc.3.1338308408244;
        Tue, 29 May 2012 09:20:08 -0700 (PDT)
Path: pr3ni62824pbb.0!nntp.google.com!news1.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Newsgroups: comp.lang.lisp
Subject: Re: LISP style question - (with-open-file)
Date: Tue, 29 May 2012 18:20:05 +0200
Organization: Informatimago
Lines: 49
Message-ID: <87sjejx8lm.fsf@kuiper.lan.informatimago.com>
References: <fcce762a-70a6-47db-a489-6e2c8464b6cd@a1g2000yqd.googlegroups.com>
	<jq2r01$437$1@dont-email.me>
	<c3646bd6-889d-4e32-930f-c6ba41ebf7aa@v9g2000yqm.googlegroups.com>
Mime-Version: 1.0
X-Trace: individual.net /cvUQyEL8EJBohTb7Kw/zgZZFJJD6UwoL2/eAZfOExPomuVZezcSv/F5DjJRDzFJLO
Cancel-Lock: sha1:NWVhZDI0MTZkOTY3MDUyZWEyMjRhZTZkYjlkMjRkMDljMTdmZmEyZg== sha1:f7MugdgjafhsNGNRaBw9DUIquG8=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA
      oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9
      033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac
      l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR
      mV+hO/VvFAAAAABJRU5ErkJggg==
X-Accept-Language: fr, es, en
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

ccc31807 <carte...@gmail.com> writes:

> On May 29, 11:46 am, Norbert_Paul <norbertpauls_spam...@yahoo.com>
> wrote:
>> What you have writte is no recursion but a statically (lexically)
>> nested expression, but you are right: It is possible to make recursive
>> function calls in Lisp.
>
> Which actually responds to a question I didn't ask.
>
> With Perl, you can manipulate a file line by line, which would process
> a file that contains one record per line in a row oriented framework
> (like a line in a spreadsheet or a row in a database table. Or, you
> can use slurp mode to manipulate the entire file as one long string,
> if (for example) you wanted to manipulate a text file.
>
> In order to recurse on a CSV file, you would need to read the entire
> file into memory as a list, with each record becoming a list element.

There are several libraries to read or write CSV files.

(ql-dist:system-apropos "csv")


> (defun munge-data (file)
>   (cond
>     ((null file) nil)
>     (t (manipulate-record (car file))
>        (munge-data (cdr file)))))
>
> To me, it's more intuitive, less space intensive, and maybe less time
> intensive, to manipulate a file line by line iteratively that
> recursively.
>
> Comments?

Indeed.  But how often do you have to process files bigger than the RAM
nowadays?  (eg. I have 24GB of RAM in my workstation, and 4GB in my game
computer).

But yes, if you have to process multi-terabyte log files, better do it
in chunks.

clhs read-line


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.