PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 04/27/2017 2:33 PM by  JasonP
Data Files with LineFeeds and Carriage Returns Importdb
 8 Replies
Sort:
You are not authorized to post a reply.
Author Messages
JasonP
Programmer Analyst
PennState Hershey Medical Center
Advanced Member
(59 points)
Advanced Member
Posts:27


Send Message:

--
04/13/2017 12:33 PM

    I'm planning on doing any importdb on a file that contains both a line feed and a carriage return at the end of each record and that doesnt seem compatible with the importdb command.  when I use notepad++ and change the EOL to UNIX which leaves just the line feeds, the importdb works fine.  Any ideas on how to remove those Carriage returns easily?  is there some param on importdb Im missing?

    Kwane McNeal
    Private
    Private
    Veteran Member
    (1260 points)
    Veteran Member
    Posts:420


    Send Message:

    --
    04/13/2017 12:50 PM
    Look at dos2unix
    Greg Moeller
    Private
    Private
    Veteran Member
    (3906 points)
    Veteran Member
    Posts:1388


    Send Message:

    --
    04/13/2017 1:03 PM
    Or if you want to use Lawson tools look at cnvimp
     cnvimp filename 382> outfile 
    where 382 is the record length
    JasonP
    Programmer Analyst
    PennState Hershey Medical Center
    Advanced Member
    (59 points)
    Advanced Member
    Posts:27


    Send Message:

    --
    04/13/2017 2:22 PM

    with the cnvimp function, each record in the file could have a different length I suspect right? or is that a number when I open up the file in an editor, i see how many characters the max is?

     

    I also found 

    tr -d '\r' < infile > outfile
    Would either one be a better option, is there anything I could do in ipa to fix it before getting to uni?

    Greg Moeller
    Private
    Private
    Veteran Member
    (3906 points)
    Veteran Member
    Posts:1388


    Send Message:

    --
    04/13/2017 2:44 PM
    most of the input files for Lawson (unless they are csv) should have the same length. There is documentation on InforXtreme that will tell you what the lengths should be. It varies depending on which table you want to import into.
    Any of these solutions could conceivably be run in IPA.
    Kyle Jorgensen
    Programmer/Analyst
    WoodmenLife
    Veteran Member
    (314 points)
    Veteran Member
    Posts:116


    Send Message:

    --
    04/14/2017 7:47 AM
    We use AIX, which doesn't come delivered with the 'dos2unix' and 'unix2dos' utilities.
    We wrote our own little shell scripts to do the same thing.
    Below is the heart of each script for these scripts.

    "unix2dos" - remove carriage return characters:
     tr -d '\r' < $1 > $2 


    "dos2unix" - add carriage return characters:
     awk 'sub("$", "\r")' $1 > $2 
    Kyle Jorgensen
    Programmer/Analyst
    WoodmenLife
    Veteran Member
    (314 points)
    Veteran Member
    Posts:116


    Send Message:

    --
    04/14/2017 7:50 AM
    Awe, shoot...the 'code' tags changed the syntax a little....

    The ' string in my code are single quote characters.

    Let me try adding them without using the code tags....no promises....
    tr -d '\r' < $1 > $2
    awk 'sub("$", "\r")' $1 > $2

    Srini Rao
    Private
    Private
    Veteran Member
    (294 points)
    Veteran Member
    Posts:138


    Send Message:

    --
    04/14/2017 10:41 AM
    Try this...

    sed 's/~!//g' $file > $TempFile
    tr -d -i $TempFile -o $OutFileName '"\r"'


    JasonP
    Programmer Analyst
    PennState Hershey Medical Center
    Advanced Member
    (59 points)
    Advanced Member
    Posts:27


    Send Message:

    --
    04/27/2017 2:33 PM
    Thanks for all the responses, Im good.
    You are not authorized to post a reply.