Re: Want to replace SPACE delimited data file with commas



There will always be three fields after the description EXCEPT I am
looking for the group of records that has only TWO after the
description.
I dont care about the other records

It will be records that start with 052. They will only have two fields
after the description.
And they will be the only ones delimited by spaces. The other records
have commas.
The fields for 052 records are separated by spaces not tabs
The fields for all records are length determinable by position. Meaning
if I took out the commas I still would know when they start and end.

1-3 zone
5-15 code
etc etc

I will have to preview my post next time so it wont wrap. Every line
starts with a three digit id always so 003 is the start of a new line.

This is a dump from an Oracle DB so I would have to find the pl/sql
code for tab ( chr(10) I think ) as I am using the PL/SQL file I/O API
to write this file

Thanks for your help this gets me started

Stephane CHAZELAS wrote:
2006-12-6, 11:38(-08), CarltonG:
Hello,
I have a datafile that looks like this:
003 68441896104 8 CHEERLEADER BEAR 0510 00001599 00000000
003 68441896108 8 VARSITY BEAR 0510 00001599
00000000
003 68441896106 SAILOR BEAR WHITES 0510 00001599
00000000
003 336037204651 SENSI WMN 3.4 SPR 0592 00006000
00000000
003 76968229001 111404 0597
00001299 00000000

I want to be able to define a specific id ( in this case 003 ) and for
all those records
replace the spaces that seperate each value with a comma.
Problem is the third value ( description ) has spaces in it.

I know awk can get each file but I honestly dont know the possible
number of spaces that could be in the description field.

Can anyone point me in the right direction? I think this is pretty
complex but I could be wrong.
[...]

If the number of fields before and after the 3rd field is
always the same, I'd go for sed:

b='[[:blank:]]\{1,\}' # blanks
f='\([^[:blank:]]\{1,\}\)' # single word field

sed "s/^$f$b$f$b\(.*[^[:blank:]]\)$b$f$b$f$b$f$/\1,\2,\3,\4,\5,\6/"

--
Stéphane

.



Relevant Pages

  • Re: How to protect VB script in Db
    ... then project properties it has 2 tabs and the 2nd tab has an option to ... dont want to click and lock somthing if i dont know anything about it. ... the db was not an MDA file it was a self contained mdb file. ...
    (microsoft.public.access.modulesdaovba)
  • Re: moving across tabs in firefox
    ... Dont know ... Ah grasshopper, they are so! ... This is because tabs on your desktop are ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: The RMIM Switch Debate -- A "Philosophical" View
    ... tabs wrote: ... they dont need any incentive for that. ... contentment, though the source of your own depression and ... To make this relevant to RMIM, we may re-interpret the misra' ...
    (rec.music.indian.misc)
  • Re: saving to csv file from excel 2007
    ... I did that and the 2007 file has several commas after the information where ... the 2003 file doesn't - that is the difference but I dont know how to correct ... "Bernard Liengme" wrote: ... resizing it etc. ...
    (microsoft.public.excel.newusers)
  • Re: CSS menu - changing colors of tab - do I need a css file for each color? a better way?
    ... > Hi Els ... > I still dont think you catch what I getting at, ... Click the main tabs and see how main tab and sub tabs change ... Sonhos vem. ...
    (comp.infosystems.www.authoring.stylesheets)