473,513 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open text file and remove 2 spaces from every row

7 New Member
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 2494
Dököll
2,364 Recognized Expert Top Contributor
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

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

Similar topics

6
3531
by: BadOmen | last post by:
I have a text file that I want to save from my program. But I don't want to save the empty lines. I want to delete everything after the last character, Is that possible? Then when I read the...
9
2091
by: Tom Weston | last post by:
Help I have 4 databases containing different data relating to safety, not written by me. It is not possible to merge the databases into one large data base. I would like to create a user interface...
14
4165
by: Thelma Lubkin | last post by:
I am trying to limit the user's options to the choices offered by the combobox text, but I don't want this to extend to how he spaces out the text, e.g. 'abcdefg' and 'ab cd efg' should be...
0
1682
by: Alex Egg | last post by:
I have this unformated text file, "demo.txt"... Now I need to be able to process it... By, processing it, I mean... After every 2 characters in the file, add 1 space, " "... Now there...
4
2128
by: John | last post by:
I can create text file, but how can I create a text file where the values are at the same location on every line? I want to define the location where the values starts and define the length of...
8
4451
by: someone | last post by:
I'm making an program that encodes text, and then writes it into another text file. The problem is that I can't seem to get the "file exists" checking right. If I use the command (coder is the...
7
1613
by: Lenard Redwood | last post by:
I'd like to create a simple chat application that will leave the connection open for a minute and then restart the connection to the server to push data. I plan to use temporary .txt files to store...
24
2456
by: Marc Dubois | last post by:
hi, is it possible to parse an XML file in C so that i can fulfill these requirements : 1) replace all "<" and ">" signs inside the body of tag by a space, e.g. : Example 1: <fooblabla < bla...
3
8774
kamill
by: kamill | last post by:
how can i remove blank spaces from text file......is there any function to remove a perticular chr from file...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.