If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > help me please.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-06-04, 09:28
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 283
Thumbs down help me please.

Hi,

I have a flat file, exaple.

aaaa bbbbb cccc ddddd eee ffff
aaaa bbbbb cccc ddddd eee ffff
aaaa bbbbb cccc ddddd eee ffff
aaaa bbbbb cccc ddddd eee ffff

I need put it a pipe line in aech field, the flat file must be
so as.
aaaa|bbbbb|cccc|ddddd|eee|ffff
aaaa|bbbbb|cccc|ddddd|eee|ffff
aaaa|bbbbb|cccc|ddddd|eee|ffff
aaaa|bbbbb|cccc|ddddd|eee|ffff

thank you for yuor help.
Reply With Quote
  #2 (permalink)  
Old 07-06-04, 09:34
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
what is the field separator on the file now?
if it is a tab, you can do something like this
:g/"tab here"/s//|/g
this will replace all of the tab fields with pipes (this is in vi)
or if it is a space same thing
:g/ /s//|/g

Good luck
Reply With Quote
  #3 (permalink)  
Old 07-06-04, 13:04
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 283
thank you for you help.

In this moment the separator is spaces, but in the start each
line and end each line there are n spaces, how to delete this spaces in each line in the flat file from prompt.

Thank you.
Reply With Quote
  #4 (permalink)  
Old 07-06-04, 13:44
mjldba mjldba is offline
Registered User
 
Join Date: Dec 2003
Location: North America
Posts: 139
Hi,

I'll assume that you're extracting your flatfile from some Informix tables via SQL so have you tried specifying the piping symbol as your delimiter when you unload the data & create the flatfile?

something like:

unload to "flat_file" delimiter "|"
select * from some_table

Only problem would be each line of the flatfile will end with a piping symbol
Reply With Quote
  #5 (permalink)  
Old 07-06-04, 15:37
mjldba mjldba is offline
Registered User
 
Join Date: Dec 2003
Location: North America
Posts: 139
If the source of your flatfile is NOT data extracted from an Informix table via SQL, that is, you received the flat file from some other source, you could use the streams editor (sed) from a command line prompt.

sed 's/ /|/g' original_flatfile > new_flatfile <cr>

This'll change every occurance of a blank space on every line in the file to a piping symbol. It will work so long as there are no embedded spaces in any of the aaaa bbbb cccc dddd eeee ffff column data.

The original file remains unchanged so using sed is a non-destructive
approach to your problem.

Good luck

Mike
Reply With Quote
  #6 (permalink)  
Old 07-07-04, 03:26
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 283
Hi,

In this moment the output file is so for example.
aaaa|bbbbb|cccccc


but, at the right the last field there are space in blank,
how to delete this spaces and how to put pipe line at the
end of field cccccc.

thank you for you help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On