all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "HS" <hugows@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: file filtering
Date: 31 Jan 2007 04:50:10 -0800	[thread overview]
Message-ID: <1170247808.259815.196930@p10g2000cwp.googlegroups.com> (raw)
In-Reply-To: <ups8vpqqv.fsf@gmail.com>

On 31 jan, 05:05, Peter Tury <tury.pe...@gmail.com> wrote:
> "HS" <hug...@gmail.com> writes:
> > Excuse me for saying that here, but do you really need/want to use
> > elisp?
>
> You are right: I don't really need, but I do really want... ;-) More
> precisely: I have an elisp fun what does what I need, but not exactly
> in the way I could really like. So I asked here if it is possible to
> do in some better way or not. From (lack of) early answers it seems:
> not nice way exists :-(
>
> > It seems much easier and "logical" to solve this problem - since
> > it's a command-line script that will do some text processing - with
> > Ruby, Python or Perl.
>
> Yes. Usually. But can exist cases when this would be part of a bigger
> "system" what is "logical to implement" in elisp... Why mix it up with
> other languages if not really needed?

Hm... I can't imagine how "not to read into a buffer"...
I just tried something like this, and it works:

(defun process-file (file)
  (interactive "f")
  (with-temp-buffer
    (insert-file-contents file)
	(delete-non-matching-lines "valid [0-9]+")
	(replace-regexp "valid \\([0-9]+\\)" "I found a \\1" )
	(write-file "test2.txt" nil)))

-------- input file ----------------
blablabla
valid 39
idasuiahsduihas
valid 123
dasuiohdiuahs
dasuiohduahs
dasudhas
valid 29
dasiuhuidah
dasjddij
d
d
asijdsj

-------- output file --------
I found a 39
I found a 123
I found a 29

Don't know if you can use something from that, but anyway :)
Good luck,
HS

  reply	other threads:[~2007-01-31 12:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-30 15:34 file filtering Peter Tury
2007-01-30 16:58 ` HS
2007-01-31  8:05   ` Peter Tury
2007-01-31 12:50     ` HS [this message]
2007-01-31 13:34       ` Peter Tury
2007-01-31 14:51         ` HS
2007-02-01  7:47           ` Peter Tury
2007-02-01 14:26             ` Mathias Dahl
2007-02-04 17:18             ` Kevin Rodgers
     [not found]             ` <mailman.3999.1170609530.2155.help-gnu-emacs@gnu.org>
2007-02-14 12:19               ` Peter Tury
2007-02-01  5:55 ` Kevin Rodgers
     [not found] ` <mailman.3856.1170309361.2155.help-gnu-emacs@gnu.org>
2007-02-14 12:49   ` Peter Tury

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1170247808.259815.196930@p10g2000cwp.googlegroups.com \
    --to=hugows@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.