473,386 Members | 1,790 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,386 software developers and data experts.

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 2615
Sa***********@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.
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.txt

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...@schwabcenter.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.

/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.txt

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...@schwabcenter.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...@gmail.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...@gmail.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
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
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...
2
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
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...
1
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
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);...
0
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
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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,...
0
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
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,...

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.