* Re: Easy for Some
2010-01-04 10:25 ` marioepsley
@ 2010-01-04 16:28 ` Vicente Hernando Ara
2010-01-04 17:45 ` Peter Dyballa
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Vicente Hernando Ara @ 2010-01-04 16:28 UTC (permalink / raw)
To: marioepsley; +Cc: Help-gnu-emacs
An easy way, without coding any function is using rectangles.
* You open the keyframe file.
* Put the pointer in the first 0 of 0.xxxx number.
* Set the mark with: C-space.
* Go to the last number of the last keyframe. E.g: 0.411811 last 1
* Now kill the rectangle: C-x r k
* Create the new file where you want to save the data, and open it.
* Yank the rectangle: C-x r y
* Save the file.
It is done. :-)
On 04/01/2010, marioepsley <marioepsley@aol.com> wrote:
>
> 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.
> --
> View this message in context:
> http://old.nabble.com/Easy-for-Some-tp27011067p27011067.html
> Sent from the Emacs - Help mailing list archive at Nabble.com.
>
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Easy for Some
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
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Peter Dyballa @ 2010-01-04 17:45 UTC (permalink / raw)
To: marioepsley; +Cc: Help-gnu-emacs
Am 04.01.2010 um 11:25 schrieb marioepsley:
> I am a complete newbie, i downloaded aquamacs emacs yesterday, tried
> to use
> replace string as a guess
You could use awk to print only the second column, i.e., the second by
white space separated word of each line, when it exists in this
record. Then it would also output the second word of the header lines
which you'd need to filter:
awk '{if (NF > 1) print $2}' <file name> | egrep -v '[^-0-9.]'
--
Greetings
Pete
"Klingons do not believe in indentation - except perhaps in the skulls
of their project managers."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Easy for Some
2010-01-04 17:45 ` Peter Dyballa
@ 2010-01-05 2:23 ` Kevin Rodgers
0 siblings, 0 replies; 10+ messages in thread
From: Kevin Rodgers @ 2010-01-05 2:23 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa wrote:
>
> Am 04.01.2010 um 11:25 schrieb marioepsley:
>
>> I am a complete newbie, i downloaded aquamacs emacs yesterday, tried
>> to use
>> replace string as a guess
>
>
> You could use awk to print only the second column, i.e., the second by
> white space separated word of each line, when it exists in this record.
> Then it would also output the second word of the header lines which
> you'd need to filter:
>
> awk '{if (NF > 1) print $2}' <file name> | egrep -v '[^-0-9.]'
You (almost) never need to pipe awk's output through (e)grep:
awk 'NF == 2 && $2 ~ /^[0-9]+\.[0-9]+$/ {print $2}' FILE
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Easy for Some
2010-01-04 10:25 ` marioepsley
2010-01-04 16:28 ` Vicente Hernando Ara
2010-01-04 17:45 ` Peter Dyballa
@ 2010-01-04 20:40 ` Andreas Politz
2010-01-05 2:44 ` Steve Revilak
2010-01-05 15:40 ` Memnon Anon
4 siblings, 0 replies; 10+ messages in thread
From: Andreas Politz @ 2010-01-04 20:40 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Easy for Some
2010-01-04 10:25 ` marioepsley
` (2 preceding siblings ...)
2010-01-04 20:40 ` Andreas Politz
@ 2010-01-05 2:44 ` Steve Revilak
2010-01-05 15:40 ` Memnon Anon
4 siblings, 0 replies; 10+ messages in thread
From: Steve Revilak @ 2010-01-05 2:44 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]
>From: marioepsley <marioepsley@aol.com>
>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
This isn't really an emacs answer, but
cut -f3 foo.txt
should do what you want (assuming that your data is in a file called
"foo.txt").
>I am a complete newbie, i downloaded aquamacs emacs yesterday
Since you mentioned aquamacs, I'm going to guess that you're using a
Mac. If so, you'll need to run `cut' from within Terminal.app.
Of, if you want to do it within emacs, open the file with emacs and try
C-x h ESC 1 ESC | cut -f3 RET
Broken down, this is
C-x h ;; selects entire buffer
ESC 1 ESC | ;; ESC | pipes region to a command. ESC 1 is
;; a prefix argument that means "replace the region
;; with the output of the command"
cut -f3 RET ;; This is the command you're running on the region
Steve
[-- Attachment #2: Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Easy for Some
2010-01-04 10:25 ` marioepsley
` (3 preceding siblings ...)
2010-01-05 2:44 ` Steve Revilak
@ 2010-01-05 15:40 ` Memnon Anon
2010-01-05 17:33 ` Memnon Anon
4 siblings, 1 reply; 10+ messages in thread
From: Memnon Anon @ 2010-01-05 15:40 UTC (permalink / raw)
To: help-gnu-emacs
marioepsley <marioepsley@aol.com> writes:
> 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
[...]
> and i want to be left with just the raw values like this:
>
> 0.17489
> 0.261281
> 0.361762
[...]
> 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.
I am no programmer, too; I think I would go with emacs keyboard macros.
You do not need any extra tools or special programing knowledger:
Just the basic emacs commands.
See this:
,----[ (info "(emacs)Keyboard Macros") ]
| You define a keyboard macro by executing and recording the commands
| which are its definition. Put differently, as you define a keyboard
| macro, the definition is being executed for the first time. This way,
| you can see the effects of your commands, so that you don't have to
| figure them out in your head. When you close the definition, the
| keyboard macro is defined and also has been, in effect, executed once.
| You can then do the whole thing over again by invoking the macro.
`----
hth
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Easy for Some
2010-01-05 15:40 ` Memnon Anon
@ 2010-01-05 17:33 ` Memnon Anon
0 siblings, 0 replies; 10+ messages in thread
From: Memnon Anon @ 2010-01-05 17:33 UTC (permalink / raw)
To: help-gnu-emacs
Memnon Anon <gegendosenfleisch@googlemail.com> writes:
> marioepsley <marioepsley@aol.com> writes:
>> I am a complete newbie, i downloaded aquamacs emacs yesterday
Ah, you are probably not that familiar with the emacs info system, yet.
(You really should learn how to use it properly if you want to stick to
emacs. It is really worth getting accustomed to it!)
So, in case you did not notice:
[ (info "(emacs)Keyboard Macros") ]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use mouse on this ;).
And yes, you can use awk, pipes, regexes etc. There are lots of ways.
But, as you are no "coder" and an emacs beginner, I'd really say: Go for
the Keyboard Macros [F3+F4 or C-x ( and C-x )]. They will be usefull
again and again.
^ permalink raw reply [flat|nested] 10+ messages in thread