I have a large text file which is basically a stream of data all pretty much compressed together for each row. I've been asked to look into the failure of certain data in some columns. The data is not delimited in any way. I do however have a list of "column" lengths and comments on whether there's relevant data in each "column".
I'd use Excel, but the limit of Excel to delimit by columns is restricted to 1000 characters per row, and each row goes well beyond this. A number of these fields have strings of 30 spaces that act as filler and there's at least a good 15 or so of these... I'm hoping to parse these designated "empty" fields out.
What I need is a way that I can feed my file in and with an array that I can provide which has the column lengths and maybe a marker like "X" to ignore the respective columns I want to ignore, have it spit out a new file with delimiters, which I can then feed back into Excel for analysis.
For example if I had a file with a row like aaaaaabbbbbccccdddddeeeffffff
and I feed this file in with an array of [6 5 4X 5 3X 6]
it would spit out a file with aaaaaa^bbbbb^ddddd^ffffff
in that row.
Is there a way this can be done with grep
, awk
or sed
?
Thanks in advance.
^
to be the exact delimiter in resulting rows?