in reply to Re: Split tab-separated file into separate files, based on column name
in thread Split tab-separated file into separate files, based on column name
The following code is buggy, sorry.
... it will create empty files for each field ...
D:\tmp>type 1,George,CEO 1 George CEO D:\tmp>
strange behavior... (Update: see solution here )
so if you don't mind having the column head included you can go even shorter
D:\tmp>del id,name,position D:\tmp>perl -lanE "open $FH[$x++], '>', $_ for @F;print $_ shift @F f +or @FH" data.txt D:\tmp>type id,name,position id id 1 2 3 name name Nick George Christina position position boss CEO CTO D:\tmp>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Split tab-separated file into separate files, based on column name (updated)
by jcb (Parson) on Aug 28, 2020 at 01:17 UTC | |
by LanX (Saint) on Aug 28, 2020 at 07:25 UTC | |
by jcb (Parson) on Aug 28, 2020 at 23:26 UTC | |
by LanX (Saint) on Aug 28, 2020 at 23:58 UTC |