'how do I ' 100 -> 'how do I'; 100 
Author Message
 'how do I ' 100 -> 'how do I'; 100

i have output from database file in the format
'some string'<space>1234<space>[<maybe some other string or number>] and
so on
in other words: space separated output, strings enclosed in '<string>'

how can I separate the fields with <semicolon><space> instead of just
<space>
regards
J?rgen from Denmark



Sun, 15 Dec 2002 03:00:00 GMT  
 'how do I ' 100 -> 'how do I'; 100


Quote:
>i have output from database file in the format
>'some string'<space>1234<space>[<maybe some other string or number>] and
>so on
>in other words: space separated output, strings enclosed in '<string>'

>how can I separate the fields with <semicolon><space> instead of just
><space>

I'd recommend these methods (in order of my preference):

awk 'BEGIN{OFS="; "}$1=$1' infile

or

awk '{OFS="; ";$1=$1;print}' infile

or

awk '{gsub(/  */,"; ");print}' infile

takes this infile:

AJLW,more of line 1
12345,rest of line 2
AJWL,more of line 3
1234,rest of line 4
JWLA,more of line 5
123456,rest of line 6

and produces this output:

AJLW,more; of; line; 1
12345,rest; of; line; 2
AJWL,more; of; line; 3
1234,rest; of; line; 4
JWLA,more; of; line; 5
123456,rest; of; line; 6

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Mon, 16 Dec 2002 03:00:00 GMT  
 'how do I ' 100 -> 'how do I'; 100

Quote:

>i have output from database file in the format
>'some string'<space>1234<space>[<maybe some other string or number>]
>and so on in other words: space separated output, strings enclosed in
>'<string>'

>how can I separate the fields with <semicolon><space> instead of just
><space>

This is a variation on "CSV" files, but in this case the field
separator is a space rather than a comma and the string delimiter is a
single quote rather than a double quote. There has been MUCH written
about parsing "CSV" files in this newsgroup. Search comp.lang.awk in
http://www.deja.com for postings including "CSV" written by PEZ (I
forget his e-mail address).

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 16 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. httplib and '100 Continue' after POST

2. '20' <= 100

3. Clipper Summer'87 cpu load 100%

4. What's happening with my P-100?

5. Generating 100's of Objects

6. 100% private, 100% offshore 100% crap 8347.

7. 100% Offshore, 100% Private, 100% Online 8347

8. errors when doing 'make test'

9. Have you ever done 'namespace delete ::'?

10. 100 digits x $ 100 challenge

11. AMD 486DX/100 or Intel 486DX/100?

12. stream('file','c','seek ='x) problem

 

 
Powered by phpBB® Forum Software