Parse txt file

  • Thanks for responses... I think the problem is data related...  When I run the following query I finding some of the records starting with

    /* and

    /*

    Where it's failing is the 4th record where the eye-catcher /* has a space before /*

     

     

    Select * from

    PSFileOrder

    where

    psfile not like '%:%' and psfile <> ' '

    and psfile like ('% /*%')

     

     

  • then its time for you to read the manuals - keyword TRIM

  • I was able to fix the source that creates the jobs.txt and remove the space at the beginning of some of the records. Now The Code supplied by Jeff works as expected...

     

    Thanks to you both and sorry for some of posts I really appreciate your help..

    Jeff,

    Will try to make sure I follow the rules and suggestions when asking for help.

  • Do all of the files have a similar issue?  Perhaps you need to tweak the code to handle the anomalies.  Frederico offered a hint about that above.

    And, no... they're not rules.  They're just common sense.  We can't help you if you come in and say you need help fixing the car but won't even provide a picture of the problem never mind let us look at the car. 😉

     

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden wrote:

    Do all of the files have a similar issue?  Perhaps you need to tweak the code to handle the anomalies.  Frederico offered a hint about that above.

    And, no... they're not rules.  They're just common sense.  We can't help you if you come in and say you need help fixing the car but won't even provide a picture of the problem never mind let us look at the car. 😉

    Edit... was in a hurry and misread your post.  You fixed the issue at the source, which is an even better solution.  Well done there!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • This was removed by the editor as SPAM

  • Bruin wrote:

    I was able to fix the source that creates the jobs.txt and remove the space at the beginning of some of the records. Now The Code supplied by Jeff works as expected...

    If you have control over the source creation why not just create it in a more usable format in the first place..... >.<

  • Jeff Moden wrote:

    Jeff Moden wrote:

    Do all of the files have a similar issue?  Perhaps you need to tweak the code to handle the anomalies.  Frederico offered a hint about that above.

    And, no... they're not rules.  They're just common sense.  We can't help you if you come in and say you need help fixing the car but won't even provide a picture of the problem never mind let us look at the car. 😉

    Edit... was in a hurry and misread your post.  You fixed the issue at the source, which is an even better solution.  Well done there!

    If he can fix the output at the source - then it shouldn't be too difficult to fix that source to output data that is much easier to parse.  Even if this is just being output from a bunch of print statements to a console - you can add a line of text output that is formatted as a delimited list of elements or even create a separate file.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • ZZartin wrote:

    Bruin wrote:

    I was able to fix the source that creates the jobs.txt and remove the space at the beginning of some of the records. Now The Code supplied by Jeff works as expected...

    If you have control over the source creation why not just create it in a more usable format in the first place..... >.<

    Major chicken dinner right there.  😀 It's funny, I had that same revelation just a wee bit ago and came here to post nearly the same words as what you posted above.  Writing the data directly to a staging table would be even better but at least a more normal, "columunised" TSV would make life a whole lot easier.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • What I meant was after this file was generated I could alter the output to correct the issues. The initial creation of the file was some generated process from the App which I have "No Control".

     

    thx

  • Bruin wrote:

    What I meant was after this file was generated I could alter the output to correct the issues. The initial creation of the file was some generated process from the App which I have "No Control".

    thx

    Then that really isn't a solution to the problem - since you would need someone to manually 'fix' the file every time you want to process.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 11 posts - 46 through 55 (of 55 total)

You must be logged in to reply to this topic. Login to reply