Results 1 to 6 of 6

Thread: help me please.

  1. #1
    Join Date
    Dec 2002
    Location
    Madrid - Spain
    Posts
    422
    Provided Answers: 1

    Thumbs down Unanswered: 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.

  2. #2
    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

  3. #3
    Join Date
    Dec 2002
    Location
    Madrid - Spain
    Posts
    422
    Provided Answers: 1

    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.

  4. #4
    Join Date
    Dec 2003
    Location
    North America
    Posts
    146
    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

  5. #5
    Join Date
    Dec 2003
    Location
    North America
    Posts
    146
    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

  6. #6
    Join Date
    Dec 2002
    Location
    Madrid - Spain
    Posts
    422
    Provided Answers: 1
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •