Re: SOLVED: scripting: split into seperate files based on line contents

2009-01-17 Thread Linus Neumann
John Beckett Tim Chase Teemu Likonen Mansour Al Akeel Max Warterman Antony Scriven Tony Mechelynck Agathoklis D. Hatzimanikas Gentlemen, thank you very much for your prompt and generous support. My problem was solved in no time and I gained valuable insights to vim scripting and advanced text

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Agathoklis D. Hatzimanikas
On Fri, Jan 16, at 12:47 Agathoklis D. Hatzimanikas wrote: Thats the problem when you try to find a meaningful name for a script in the last second. > let parser = {} let linus = {} > let parser['delim'] = { let linus['delim'] = { > \ 'dat' : '' > \, 'csv' : ';' > \ } > >

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Agathoklis D. Hatzimanikas
On Wed, Jan 14, at 06:45 Linus Neumann wrote: > > Dear all, > > to continue with my diploma thesis, I have a particular problem to > solve and I believe that VIM-scripting might be the most convenient > way to do so - please correct me, if I am wrong. > > I have no more than very basic prog

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Tony Mechelynck
On 14/01/09 18:45, Linus Neumann wrote: > Dear all, > > to continue with my diploma thesis, I have a particular problem to > solve and I believe that VIM-scripting might be the most convenient > way to do so - please correct me, if I am wrong. > > I have no more than very basic programming or scri

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Antony Scriven
On Wed, Jan 14, 2009 at 5:45 PM, Linus Neumann wrote: > [...] > > What is the script supposed to do? (relevant) The .dat or > .csv file needs to be split up into seperate .txt-Files, > based on certain variables, that are contained in the > .dat/.csv-file. > > Here for a (shortened) exam

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Max Waterman
Linus Neumann wrote: > I tried it an a tab-delimited .dat file (as I unterstand that it > transfers commas to dots - and as Max correctly warned me, the > generated .csv are anything but comma-seperated...) > This is a problem that perl was made for. I'm sure you can massage the script on th

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Mansour Al Akeel
I tested it on my system with gawk: GNU Awk 3.1.6 I am not sure which awk you are using. Usually you can find out by: awk -W version Try to use a delimeter after the print statment. For example: print $0 > out ; instead of: print $0 > out If that doesn't work, then just put the awk line in

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Teemu Likonen
Linus Neumann (2009-01-14 18:45 +0100) wrote: > What is the script supposed to do? (relevant) > The .dat or .csv file needs to be split up into seperate .txt-Files, > based on certain variables, that are contained in the .dat/.csv-file. Awk is good in these things. The following script should

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Tim Chase
> What is the script supposed to do? (relevant) > The .dat or .csv file needs to be split up into seperate .txt-Files, > based on certain variables, that are contained in the .dat/.csv-file. > To sum it up: > - Var 1 is the file number: fl_grVAR1 > - Var 2 determines mw/wm: fl_grVAR1VAR1.txt >

RE: scripting: split into seperate files based on line contents

2009-01-15 Thread John Beckett
Linus Neumann wrote: > This is perfectly correct! I'm in a rush, so following hasn't really been properly read. However, give it a go and report back. ---start--- " Put following in file parse.vim " Use Vim to open first data file. " Enter command::so parse.vim " Enter command::call Pars

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Linus Neumann
Mansour Al Akeel wrote: > I am not sure if this will do it for you. > > cat sample.txt | tr ',' '.' | awk '{ out="fl_gr"$1"mw.txt" ; if ($2 == > 2) out="fl_gr"$1"wm.txt" ; $1=$2=""; print $0 > out}' Wow, what a short line of code, and to my amateur eyes it seems to contain everything relevant.

Re: scripting: split into seperate files based on line contents

2009-01-15 Thread Linus Neumann
John Beckett wrote: > please confirm procedure: > (...) > Is that correct? Anything else? This is perfectly correct! > 3. f1 is a smallish integer (1, 2, 3, ...). f1 is an integer might range to something like 17 or 20 at most. Thank you very much! Linus --~--~-~--~~---

Re: scripting: split into seperate files based on line contents

2009-01-14 Thread Max Waterman
I have a comment: be careful if your input file is truely a csv file. If the file is generated by some other program (not sure what SPSS is), then, in my experience, csv can be more complicated than you might expect (it can add quotes around the fields and escape various character/etc/etc). I

Re: scripting: split into seperate files based on line contents

2009-01-14 Thread Mansour Al Akeel
I am not sure if this will do it for you. cat sample.txt | tr ',' '.' | awk '{ out="fl_gr"$1"mw.txt" ; if ($2 == 2) out="fl_gr"$1"wm.txt" ; $1=$2=""; print $0 > out}' On Wed Jan 14,2009 06:01 pm, Linus Neumann wrote: > > Dear all, > > to continue with my diploma thesis, I have a particular

RE: scripting: split into seperate files based on line contents

2009-01-14 Thread John Beckett
Linus Neumann wrote: > I have a particular problem to solve... No doubt someone familiar with awk and other tools would already have solved this, but it looks very achievable in Vim. To save me pondering too much, please confirm procedure: 1. You will work on one input file at a time (manually r

scripting: split into seperate files based on line contents

2009-01-14 Thread Linus Neumann
Dear all, to continue with my diploma thesis, I have a particular problem to solve and I believe that VIM-scripting might be the most convenient way to do so - please correct me, if I am wrong. I have no more than very basic programming or scripting skills, so I will have to rely on your g