Data Files with LineFeeds and Carriage Returns Importdb

 8 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
JasonP
Advanced Member
Posts: 28
Advanced Member

    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
    Veteran Member
    Posts: 479
    Veteran Member
      Look at dos2unix
      Greg Moeller
      Veteran Member
      Posts: 1498
      Veteran Member
        Or if you want to use Lawson tools look at cnvimp
         cnvimp filename 382> outfile 
        where 382 is the record length
        JasonP
        Advanced Member
        Posts: 28
        Advanced Member

          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
          Veteran Member
          Posts: 1498
          Veteran Member
            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
            Veteran Member
            Posts: 122
            Veteran Member
              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
              Veteran Member
              Posts: 122
              Veteran Member
                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
                Veteran Member
                Posts: 149
                Veteran Member
                  Try this...

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


                  JasonP
                  Advanced Member
                  Posts: 28
                  Advanced Member
                    Thanks for all the responses, Im good.