I have the following data from a manual database dump. I need to format the columns so that I can import them into an excel spread sheet. So far I have been able to get past the hurdles with vi and grep. Now I have one last issue that I can't get past. Here is an example of the data.
Here is what it looks like. The third column is a part description with spaces and other characters, but none one is a consistent delimiter.
-----------------------------
2 910-0158 ENCLOSURE,TOP,SMK,10-YR B 4052 1.00000 EA U J M M No
2 910-0159 ENCLOSURE,BOTTOM,SMK,10-YR E 5404 1.00000 EA U J M M No
2 910-0160 TRIMPLATE,SMK,DC D 4735 1.00000 EA U J M M No
2 910-0155 ROTATE ACTIVATE,SMK,10-YR C 4732 1.00000 EA U J M M No
2 910-0156 ROTATE DEACTIVATE,SMK,10-YR B 4733 1.00000 EA U J M M No
2 910-0157 SLIDER,ACTIVATE-DEACTIVATE,SMK,10-YR D 4734 1.00000 EA U J M M No
2 910-0171 SUPPORT PLATE,SMK,10-YR B 4737 1.00000 EA U J M M No
2 910-0149 BUTTON,PUSH TO TEST,SMK D 3828 1.00000 EA U J M M No
2 910-0150 BUTTON,HUSH,SMK E 4714 1.00000 EA U J M M No
2 910-0151 LIGHT PIPE,SMK,NGS A 1.00000 EA U J M M No
2 940-0084 CLICHE,KIDDE LOGO ONLY,5mm,"K" A 0.00000 EA U J M M No
2 0008-2305 SCREW,PAN HEAD,M2.3X6 A 2.00000 EA U J M M No
1 800-0592 ASY,SUB,PALLET,0910,4PK,C/S,288 PER A 0.00438 EA U J M M No
2 810-1339 PKG,PALLET,CORR.PAPER,43.5x49x4.5 A 1.00000 EA U P M P No
2 820-0157 LABEL,DECAL,BARCODE,4x2,FINAL PKG,FHK S 4988 57.00000 EA U J M M No
3 810-1157 LABEL,DECAL,4X2,WHT A 1.00000 EA U P M P No
2 0000-7513 PKG,EXT,43X2X7/32,HORIZONTAL 0 2.00000 EA U J M M No
2 0000-7516 PKG,EXT,39X2X7/34,HORIZONTAL 0 2.00000 EA U J M M No
The first number of each line basically lets us know how many white spaces are needed to be removed from in front of the 3rd column in order for the following columns to line up correctly. My posting has removed the white spaces but if you could see it, it would have about 20-30 spaces between the 2nd and 3rd column depending on the first number. I can't seem to get the awk script to use the sub() function properly to replace a number of white spaces with just one or just to remove it altogether. I think its my regex. But I'm sure i'm skinning the cat the wrong way this time. Any help would be appreciated. I've read many posts on white space manipulation but none really help with this situation. The dump of the database is about 60,000 lines long. Too much to manually do line by line.
chris