From: Anselm Helbig <anselm.helbig+news2009@googlemail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Easy for Some
Date: Tue, 05 Jan 2010 11:01:31 +0100 [thread overview]
Message-ID: <87k4vw7tvo.wl%anselm.helbig+news2009@googlemail.com> (raw)
In-Reply-To: <mailman.707.1262616303.18930.help-gnu-emacs@gnu.org>
Hi!
> I'm not coder but i needed to extract some information from a text file and
> some one pointed me in this direction.
>
> I have a file like this, could have up to a 1000 keyframes.:
>
>
>
> Effects Sound Keys #1 Output 1 #22
> Frame
> 0 0.17489
> 1 0.261281
> 2 0.361762
> 3 0.400085
> 4 0.411538
> 5 0.434799
> 6 0.41712
> 7 0.422151
> 8 0.43181
> 9 0.411811
>
> Just to clarify the spacings: ( 0 0.17489 )
> Just to clarify the spacings: (tab0tab 0.17489 tab)
>
> and i want to be left with just the raw values like this:
>
>
> 0.17489
> 0.261281
> 0.361762
> 0.400085
> 0.411538
> 0.434799
> 0.41712
> 0.422151
> 0.43181
> 0.411811
>
>
> I am a complete newbie, i downloaded aquamacs emacs yesterday, tried to use
> replace string as a guess...?? no joy. Dont have anyone to ask, any help is
> greatly appreciated.
There are three obvious ways to achieve this:
1. use regular expressions
if it is sufficient to get rid of the leading whitespace and number:
M-x query-replace-regexp RET ^\s-*[0-9]+\s-* RET RET
If you need to get rid of trailing whitespace as well:
M-x query-replace-regexp RET ^\s-*[0-9]+\s-*\([.0-9]+\)\s-*$ RET \1 RET
Don't be afraid, regular expressions are easier to write than to
read. Regular expressions are the tool of choice if you want to
touch only lines matching a pattern.
2. with keyboard macros
Go to start of the first line, press `C-x (' to start your keyboard
macro and do whatever you need to clean up one line and go to the
start of the next line, end your keyboard macro with `C-x )'.
Repeat your keyboard macro by giving a big prefix to C-x e,
e.g. `C-u 1000 C-x e'. It will stop when it reaches the end of the
file.
Keyboard macros are superior if you need to do some more complex
manipulations on your text, but they can easily break unless your
text structure is very rigid. They can also be a bit slow if you
need to go through a big file. Also, of course, it's easy to
understand how a keyboard macro works than to grok regular
expressions.
3. use rectangle functions
place your cursor at the start of the first line and set the mark
with `C-SPACE'. Go to the end of the file on the last line so that
the cursor (`point' in emacs lingo) is on the first column you want
to keep. Delete the rectangular portion of the buffer with
`C-x r k'.
HTH,
Anselm
--
Anselm Helbig - http://mnemonikk.org/
next parent reply other threads:[~2010-01-05 10:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.707.1262616303.18930.help-gnu-emacs@gnu.org>
2010-01-05 10:01 ` Anselm Helbig [this message]
2010-01-05 21:54 ` Easy for Some Colin S. Miller
[not found] <20100104155525.0A1DC83814@mxperim8.sea5.speakeasy.net>
2010-01-04 10:25 ` marioepsley
2010-01-04 16:28 ` Vicente Hernando Ara
2010-01-04 17:45 ` Peter Dyballa
2010-01-05 2:23 ` Kevin Rodgers
2010-01-04 20:40 ` Andreas Politz
2010-01-05 2:44 ` Steve Revilak
2010-01-05 15:40 ` Memnon Anon
2010-01-05 17:33 ` Memnon Anon
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=87k4vw7tvo.wl%anselm.helbig+news2009@googlemail.com \
--to=anselm.helbig+news2009@googlemail.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.