473,699 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read file bottom up

I need to read a huge file. The content that I want to read are
somewhere at the bottom. Can anyone please let me know a way to read
the file bottom up?
Thanks
Trupti
Feb 18 '08 #1
7 2639
Sa***********@g mail.com wrote:
I need to read a huge file. The content that I want to read are
somewhere at the bottom. Can anyone please let me know a way to read
the file bottom up?
Take a look at the istream::seekg method. It will let you position the
file-pointer at an arbitrary place in the input stream.
Feb 18 '08 #2
On Feb 18, 9:29 am, "Samant.Tru...@ gmail.com"
<Samant.Tru...@ gmail.comwrote:
I need to read a huge file. The content that I want to read are
somewhere at the bottom. Can anyone please let me know a way to read
the file bottom up?
Thanks
Trupti
$ tail my_huge_file.tx t

If that's not suitable for your environment, you
should provide some details on that.

Sean

Feb 18 '08 #3
On 18 Feb., 17:42, Jeff Schwab <j...@schwabcen ter.comwrote:
Samant.Tru...@g mail.com wrote:
I need to read a huge file. *The content that I want to read are
somewhere at the bottom. *Can anyone please let me know a way to read
the file bottom up?

Take a look at the istream::seekg method. *It will let you position the
file-pointer at an arbitrary place in the input stream.
No it will not. seek will only (portably) position you somewhere where
you have been before.

/Peter
Feb 18 '08 #4
On 18 Feb., 18:00, sean_in_rale... @yahoo.com wrote:
On Feb 18, 9:29 am, "Samant.Tru...@ gmail.com"

<Samant.Tru...@ gmail.comwrote:
I need to read a huge file. *The content that I want to read are
somewhere at the bottom. *Can anyone please let me know a way to read
the file bottom up?
Thanks
Trupti

*$ tail my_huge_file.tx t

If that's not suitable for your environment, you
should provide some details on that.

Sean
tail is not appropriate as it is not portable, not C++ and not generic
(tail is for text-files only).

/Peter
Feb 18 '08 #5
peter koch wrote:
On 18 Feb., 17:42, Jeff Schwab <j...@schwabcen ter.comwrote:
>Samant.Tru...@ gmail.com wrote:
>>I need to read a huge file. The content that I want to read are
somewhere at the bottom. Can anyone please let me know a way to read
the file bottom up?
Take a look at the istream::seekg method. It will let you position the
file-pointer at an arbitrary place in the input stream.

No it will not. seek will only (portably) position you somewhere where
you have been before.
According to what? I'm looking at the draft standard for 0x, and don't
see anything like that. The seekg method can fail, but I don't see
anything magical about "where you have been before."
Feb 18 '08 #6
On 22 Feb, 10:02, guinness.t...@g mail.com wrote:
>
* * std::ifstream file( "myfile.dat ", std::ios_base:: binary );

* * file.seekg( 0, std::ios_base:: end );
* * std::streampos const endpos = file.tellg();
* * file.seekg( 0, std::ios_base:: beg );
* * std::streamoff const file_length = file.tellg() - endpos;
// Aaagh!
std::streamoff const file_length = endpos - file.tellg();

--
Tony
Feb 22 '08 #7
On 22 Feb, 15:59, James Kanze <james.ka...@gm ail.comwrote:
Table 88 in 27.4.3.2 indicates that a distance (streamoff) can
be obtained by subtracting one streampos from another.
Although I can't find it explicitly stated, usage (and one of
the footnotes) imply to me that streamoff is integral.

Which footnote?
I think I must have been referring to footnote 174)
(in 17.4.4.7): "... types described as synonyms for
basic integral types, such as ... streamoff."

--
Tony
Feb 25 '08 #8

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

Similar topics

6
20333
by: Rajshekhar | last post by:
hi all, i would like to know how to read .xls file using fopen & getc combination (usual procedure thats follwd for read file).. any ptrs or any function that anybody can suggest?? Rajshekhar
2
527
by: Robbie | last post by:
Anybody out there know of a way to read a text file starting from the bottom of the file then going backwards line by line? I am reading large log files in which the data I'm looking for is always near the bottom. I would like something like: StreamReader sr = new StreamReader("MyFile.txt"); string line = sr.ReadLine(-1); <-- this functionality doesn't exist.
2
6314
by: Lam | last post by:
Hi the default readline method in StreamReader read the text from the top to bottom how can I read a text file from the bottom to the top? Thanks
4
2739
by: ESPN Lover | last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one way preferred over the other and why? Thanks. using System; using System.IO; class Test { public static void Main()
1
3997
by: Jose Reckoner | last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks!
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.
0
298
by: Samant.Trupti | last post by:
I need to read a huge file. The content that I want to read are somewhere at the bottom. Can anyone please let me know a way to read the file bottom up? Thanks Trupti
3
6245
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store that multiple worksheet data in different table.How can i do it.Below is my xml file. <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" ...
3
5397
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store that multiple worksheet data in different table.How can i do it.Below is my xml file. <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office"...
0
8686
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
9173
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
9033
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
7748
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
6533
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
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
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
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2345
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.