Open text file and remove 2 spaces from every row

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buggtb
    New Member
    • Apr 2007
    • 7

    Open text file and remove 2 spaces from every row

    Hi Guys,

    I've been given the joyous task of updating some very old scripts at work and I could do with a little help.

    Our Unix system dumps text files to pseudo spoolers that our windows machines can then pick up and process. Now the guy who wrote one of the reports is obviously a bit clueless and the certain lines don't match up so for example our % line is a couple of spaces too far across.

    A09
    62371
    __7.20%

    so when we import them into excel they give us quite a headache with our old automated routines as figures now end up in the wrong columns.

    So instead of re writing the script what I was planning to do was open the file remove 2 spaces from the relevant lines and re save the file then run our normal script. But how is this done?

    Eg:

    Open repidb

    For i=AmtLinesInFil e
    {
    If current line contains a '%' symbol then remove 2 spaces from the start of the line
    }
    Next i


    Something along those lines.

    I'm guessing its possible, these files also all have unix line breaks so that makes life slightly more interesting.

    If someone can point me in the right direction it would be appreciated.

    Cheers

    Tom
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hello, Tom!

    I am not sure where data are coming from to add to Excel. Have you tried TRIM command? You can look for what you need and simply trim spaces around. If you know where spaces will be and are consistent use either LTRIM (grabbing spaces to the left) or RTRIM (grabbing spaces to the right). TRIM, by itself, does it left and right. Hope this helps.

    Have a great end to your work week...

    Dököll

    Comment

    Working...