469,587 Members | 2,710 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,587 developers. It's quick & easy.

Open text file and remove 2 spaces from every row

7
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=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.

Cheers

Tom
Jun 6 '07 #1
1 2284
Dököll
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...

Dököll
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
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.