help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy for Some


From: Andreas Politz
Subject: Re: Easy for Some
Date: Mon, 04 Jan 2010 21:40:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

marioepsley <marioepsley@aol.com> writes:

> 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 many ways to solve this (See the other replies.).  Most of
them use regular expressions in one way or another.

First move to the beginning of your file and get rid of the lines you
don't want.  (All based on your example data.  'RET' means 'return/enter
key', 'M-<' means press Alt/Meta + '<', 'M-x' likewise.)

M-<
M-x keep-lines RET ^\s-*[0-9]+\s-+[0-9]+\(\.[0-9]+\)?\s-*$ RET

Back to the beginning.
M-<

Now, on every line, replace everything with the decimal number. 

M-x replace-regexp RET ^\s-*[0-9]+\s-+\([0-9]+\(\.[0-9]+\)?\)\s-*$ RET \1 RET

I hope this works.

-ap





reply via email to

[Prev in Thread] Current Thread [Next in Thread]