471,897 Members | 1,339 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,897 software developers and data experts.

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.


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?


Open repidb

For i=AmtLinesInFile
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.


Jun 6 '07 #1
1 2383
2,364 Expert 2GB
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...

Jun 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by Thelma Lubkin | last post: by
4 posts views Thread by John | last post: by
8 posts views Thread by someone | last post: by
7 posts views Thread by Lenard Redwood | last post: by
24 posts views Thread by Marc Dubois | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.