From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10b05a,eebc048575b82884,start X-Google-Attributes: gid10b05a,public X-Google-Thread: fee84,62951c700994df34 X-Google-Attributes: gidfee84,public X-Google-Thread: 107393,62951c700994df34 X-Google-Attributes: gid107393,public X-Google-Thread: f9400,62951c700994df34 X-Google-Attributes: gidf9400,public From: davis@space.mit.edu Subject: Re: Unix editors w/features for dealing with columnar data? Date: 1995/05/01 Message-ID: <3o33l5$l91@senator-bedfellow.MIT.EDU>#1/1 X-Deja-AN: 101744142 distribution: inet references: <3nr6nl$cak@news.iastate.edu> organization: Center for Space Research reply-to: davis@space.mit.edu newsgroups: comp.editors,comp.os.ultrix,comp.unix.osf.osf1,alt.lang.s-lang >We're moving a large numbers of users from a mainframe environment to >Unix. Some of them have large data files which can be described in the >following manner: (trivial example) > Columns Description > ------- ----------- > 1-4 id number > 5-24 name > 25-30 dat1 > 30-35 dat2 > ... etc >In essence, they've got what I call fixed column data. (not whitespace >separated - I'm mainframe-challenged, sorry for the wording) They're >used to using Stanford Wylbur (not the same as some commercial Wylbur >implementations) to do their editing tasks. >They do things like: > Find the lines that have '1234' in columns 1-4 and change > columns 30-35 to 'abcdef'. There are many ways to do this using JED. For example, one could use regular expression searches, keyboard macros, etc... However, if this is a routine task, I suggest something like the following function: define solution_1 () { push_spot (); % save position bob (); % goto beginning of the buffer while (bol_fsearch ("1234")) { goto_column (30); deln (6); insert ("abcdef"); } pop_spot (); % goto original position } > Find the lines with '1234' in columns 1-4 and 'dog' starting in > column 5 and insert three spaces starting in column 25. define solution_2 () { push_spot (); % save position bob (); % goto beginning of the buffer while (bol_fsearch ("1234dog")) { goto_column (25); insert (" "); } pop_spot (); % goto original position } > Find the lines with 'dog' starting in column 5 and copy columns 25-30 > to 30-35. define solution_3 () { push_spot (); % save position bob (); % goto beginning of the buffer while (re_fsearch ("^....dog")) { goto_column (25); push_mark (); go_right (5); % Now at column 30 so insert marked region insert (bufsubstr ()); } pop_spot (); % goto original position } > Find the lines longer than 35 characters and replace columns 5-24 > with 'invalid' (left justified, blank padded) define solution_4 () { push_spot (); % save position bob (); % goto beginning of the buffer do { eol (); % goto end of line if (what_column () > 35) { goto_column (5); deln (19); insert ("invalid"); insert_spaces (12); } } while (down (1)); pop_spot (); % goto original position } The latest version of jed (0.97-6) is available from space.mit.edu in pub/davis/jed. --John