From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anselm Helbig Newsgroups: gmane.emacs.help Subject: Re: Easy for Some Date: Tue, 05 Jan 2010 11:01:31 +0100 Organization: Freie Universitaet Berlin Message-ID: <87k4vw7tvo.wl%anselm.helbig+news2009@googlemail.com> References: NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1262710449 23930 80.91.229.12 (5 Jan 2010 16:54:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Jan 2010 16:54:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 05 17:54:02 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NSCfS-0007u9-6z for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jan 2010 17:54:02 +0100 Original-Received: from localhost ([127.0.0.1]:47595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSCfS-0000FJ-Mq for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jan 2010 11:54:02 -0500 Original-Xref: news.stanford.edu gnu.emacs.help:175989 Original-Path: news.stanford.edu!usenet.stanford.edu!enigma.xenitec.ca!newsfeed-00.mathworks.com!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 91 Original-X-Trace: news.uni-berlin.de XNzuHGRYCcoQny93bOIdPQPhdbh0yNm2+zt4qdoUfFg+BNrGEhoq+5nmuI Cancel-Lock: sha1:6d0RACPb3K6b2L1eQzC+ipC9KCM= In-Reply-To: Mail-Followup-To: Anselm Helbig X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71068 Archived-At: 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/