473,791 Members | 3,186 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=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
Jun 6 '07 #1
1 2521
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
3551
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 text file i don't want to read empty lines(If the user as edit the file in notpad..), sense it makes commas at all new lines and then split the text at every comma in to an array. The array will contain empty "slot's" if there is a lot of commas in a...
9
2102
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 with 4 buttons, one for each database. The aim would be for the user to click on a button and the related database opens for use. When the database is closed the user interface with the buttons on returns. Can anybody offer a method of achieving...
14
4194
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 equivalent. I know how to compare strings to see whether they meet this criterion--I don't know how to let the combobox know that this is what I want. I am thinking of dealing w/ this in the NotInList_event, but I don't know how to get to the...
0
1700
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 should be 28 groupes of characters and 27 spaces dividing them.
4
2147
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 the value.
8
4490
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 application): coder something.txt an_exsiting_file.txt, then if I chose to overwrite "an_exsiting_file.txt", an error message pops up, saying that to many files are open <EMFILE>. Any help would be appreciated. Here is the code (incomplete but still...
7
1629
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 messages. My question is how can I do that in PHP 5, what techniques should I do server-side to keep this connection open and how would be the flow of the message? Do I need a different technology such as Python to handle messages? 1. User A...
24
2507
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 </foo> becomes <fooblabla bla </foo>
3
8807
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
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10428
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.