473,392 Members | 1,250 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,392 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 2485
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

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

Similar topics

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...
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...
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...
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...
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...
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...
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...
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...
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...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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,...
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...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.