473,698 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read a text file line by line and remove some line

Can anyone please help me in writing the code in C++ :

I want a read a file line by line,remove the lines which have length of
a particular field in a line exceeding 63 characters After removing the
line the corresponding blank spaces generated after removal of the
line also needs to be removed.
..
I am in urgent need for this solution.Kindly help how to go about it.

Thanks in advance ,

Kaushik

Sep 10 '06 #1
4 2581
"kaushiksho me" writes:
Can anyone please help me in writing the code in C++ :

I want a read a file line by line,remove the lines which have length of
a particular field in a line exceeding 63 characters After removing the
line the corresponding blank spaces generated after removal of the
line also needs to be removed.
.
I am in urgent need for this solution.Kindly help how to go about it.
Where is your problem at? Can you open a file? read a line? write a line?

What is it you can't do?
Sep 10 '06 #2
In article <11************ **********@d34g 2000cwd.googleg roups.com>,
ka**********@gm ail.com says...
Can anyone please help me in writing the code in C++ :

I want a read a file line by line,remove the lines which have length of
a particular field in a line exceeding 63 characters After removing the
line the corresponding blank spaces generated after removal of the
line also needs to be removed.
.
I am in urgent need for this solution.Kindly help how to go about it.
You can't delete data from the middle of the file, so you have to copy
data from the existing file to a new file, skipping over the parts you
don't want.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Sep 10 '06 #3
Boss I am new at C++ programming.... .how can I open , read and write it
to a new file after ignoring certain lines..kindly tell me how to go
about it...(code)

Regards,

Kaushik
osmium wrote:
"kaushiksho me" writes:
Can anyone please help me in writing the code in C++ :

I want a read a file line by line,remove the lines which have length of
a particular field in a line exceeding 63 characters After removing the
line the corresponding blank spaces generated after removal of the
line also needs to be removed.
.
I am in urgent need for this solution.Kindly help how to go about it.

Where is your problem at? Can you open a file? read a line? write a line?

What is it you can't do?
Sep 10 '06 #4
Ok...let me analyse it and I shall get back to u soon..
thanks for replying..
regards,

Kaushik
Jerry Coffin wrote:
In article <11************ **********@d34g 2000cwd.googleg roups.com>,
ka**********@gm ail.com says...
Can anyone please help me in writing the code in C++ :

I want a read a file line by line,remove the lines which have length of
a particular field in a line exceeding 63 characters After removing the
line the corresponding blank spaces generated after removal of the
line also needs to be removed.
.
I am in urgent need for this solution.Kindly help how to go about it.

You can't delete data from the middle of the file, so you have to copy
data from the existing file to a new file, skipping over the parts you
don't want.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Sep 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1565
by: Majordomo | last post by:
-- >>>> --36742377 **** Command '--36742377' not recognized. >>>> Content-Type: text/plain; charset=us-ascii **** Command 'content-type:' not recognized. >>>> Content-Transfer-Encoding: 7bit **** Command 'content-transfer-encoding:' not recognized. >>>> >>>> something is fool
6
4279
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a while statement checking for an empty string "" which I understand represents an EOF in Python. The text file has some blank lines with spaces and other with blanks. Thanks a lot.
1
9295
by: Rigga | last post by:
Hi, I am new to Python and need to parse a text file and cut parts out i.e. say the text file contained 5 rows of text: line 1 of the text file line 2 of the text file line 3 of the text file line 4 of the text file line 5 of the text file
5
3159
by: Martin Svensson | last post by:
Hello! I need some help/recommendations on how to do the following. I have a program that writes an IP address two control numbers and a date to file, on one line. It's a basic text file and it looks like this: ----- beginning of file ----- 192.168.0.1 0 0 2004-08-01 192.168.0.2 1 0 2004-08-21 192.168.0.4 0 1 2004-08-12
4
7383
by: Andyza | last post by:
I'm using FileSystemObject to open and write to a tab delimited text file. First, I connect to a database and select some data. Then I create the text file and insert each record in the text file. At the end of each record I insert a vbCrLf character in the text file to create a new line. Thus each record is in a new line. The problem is that I get a tab delimited text file where the LAST LINE in the text file is always a blank line....
15
5467
by: I. Myself | last post by:
This is about reading the .ini files which are used in several of our projects. Currently, the actual read of each line of the file is with this statement: fscanf(file, "%s %s", name, value); /* reads two strings from .ini file */ This works, but it does not allow any comments to the right of the two strings.
2
3376
by: peter.vanna | last post by:
I would like to write a program to read a text file (data.txt) on Windows and Linux machines. data.txt is formated as follows: 1 10 100 1000 2 20 (a new but empty line)
6
5710
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a * vector<string>. Now, use istringstream to read read each line * from the vector a word at a time.
13
10411
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another set of integers stored in an array.It would be a great help if you could provide some code for it.I tried the function fscanf but by that I am able to read only the first integer of the text file.Please help me.
0
8680
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
8609
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
9169
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
9030
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...
0
7738
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2335
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.