8 Replies Latest reply on Mar 22, 2010 4:53 AM by Iwan Toma

    How to skip line for delimited file type?

    Iwan Toma
      Hi, i wanna ask how to skip (example: the first two line) for delimited file type?
      Thanks...


      Here is my script
      Function NY_Skip06Center [strField, strRecord]
      '------------------------------------------------------------------
      ' FDM DataPump Import Script:
      'Created by: FDM_Admin
      'Date created: 2/28/2006
      '------------------------------------------------------------------
      Dim strEntity
      'Check first two characters of entity
      For strEntity = 1 to 6
      'Skip line
      Res.PblnSKip = True
      Next strEntity
      End if
      End Function

      But it returns this error when imported
      Error: An error occurred importing the file.
      Detail: Object variable or With block variable not set

      Anyone knows what's wrong

      Edited by: user649207 on Mar 19, 2010 2:15 AM

      Edited by: user649207 on Mar 19, 2010 3:04 AM
        • 1. Re: How to skip line for delimited file type?
          JTF85
          Are you attempting to skip the first six lines of the file? Currently you are receiving an error due to an extra end if. If there is some sort of code in the first six lines of the file you may be better off skipping based on the heading then trying to go on this way.


          JTF

          Edited by: user10316846 on Mar 19, 2010 11:41 AM
          • 2. Re: How to skip line for delimited file type?
            Iwan Toma
            Skipping based on the heading?
            I've tried that but apparently i'm getting error because my delimiter is TAB and, i dont know how to parse TAB into my script.


            Function SkipBlankAcc [strField, strRecord]
            Dim strAcc
            'Store first entity in a variable
            strEntity = DW.Utilities.fParseString (strField, 1, 1, " ")
            'Check first character of account
            If Left(strAcc, 1) = " " then
            'Skip line if account is blank
            Res.PblnSKip = True
            Else
            SkipBlankAcc = strAcc
            End if
            End Function
            • 3. Re: How to skip line for delimited file type?
              TonyScalese
              The ascii code for tab is 9:

              strEntity = DW.Utilities.fParseString (strField, 1, 1, chr(9))

              Does that help?
              • 4. Re: How to skip line for delimited file type?
                Iwan Toma
                Function SkipBlankAcc [strField, strRecord]
                Dim strAcc
                'Store first account in a variable
                strAcc = DW.Utilities.fParseString (strField, 1, 1, chr(9))
                'Check first character of account
                If Left(strAcc, 1) = "" then
                'Skip line
                Res.PblnSKip = True
                Else
                SkipBlankAcc = strAcc
                End if
                End Function

                I still got an error...
                Anything wrong?
                Thanks...

                I wanna skip the line where there is no account specified in that line...
                • 5. Re: How to skip line for delimited file type?
                  TonyScalese
                  strAcc = DW.Utilities.fParseString (strField, 1, 1, chr(9))

                  I didn't look closely enough last time. The above is illogical. The parsestring function parses a string based on a delimiter.

                  The function has these arguments:

                  String to Parse
                  How many fields are in the string
                  The parsed field to return
                  Field delimiter

                  In the above, strField is returning the field specified in your import format. You are also saying that there is a total of 1 field. If that were the case, you wouldn't need to parse anything.

                  I am guessing that your call needs to look something more like this:

                  strAcc = DW.Utilities.fParseString (*strRecord*, *8*, 1, chr(9))

                  Make sense?

                  If not, maybe you can include a few sample lines from your data file and that will make it easier to help you.

                  Is your import format fixed or delimited?
                  • 6. Re: How to skip line for delimited file type?
                    Iwan Toma
                    My txt file is tab delimited...
                    Sample (I've replaced all tab into space):

                    Acct AcctName Debit Credit Ending Adjusted
                    1000.001 Petty Cash 0 100 100 0
                    Total 0 100 100 0

                    My script is like this now...
                    Function SkipBlankAcc [strField, strRecord]
                    Dim strAcc
                    'Store first account in a variable
                    strAcc = DW.Utilities.fParseString (strField, 6, 1, chr(9))
                    'Check first character of account
                    If IsNull(strAcc) = True then
                    'Skip line
                    Res.PblnSKip = True
                    Else
                    SkipBlankAcc = strAcc
                    End if
                    End Function


                    My aim is to skip all null in 1st field

                    Edited by: user649207 on Mar 21, 2010 9:49 PM
                    • 7. Re: How to skip line for delimited file type?
                      TonyScalese
                      You're overcomplicating it.

                      Your script can be this:

                      Function SkipBlankAcc(strField, strRecord)

                      If Trim(strField) = "" then
                      Res.pblnSkip = True
                      End if

                      SkipBlankAcc = strField

                      End Function


                      If this works for you, please flag the answer as correct so others can benefit.
                      • 8. Re: How to skip line for delimited file type?
                        Iwan Toma
                        Yah, you're right.
                        I'm overcomplicating it.
                        Thanks for the answer, Tony