[C++] append() to each row of a text file

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 4
Reputation: sylvaticus is an unknown quantity at this point 
Solved Threads: 0
sylvaticus sylvaticus is offline Offline
Newbie Poster

[C++] append() to each row of a text file

 
0
  #1
Oct 16th, 2007
Hello.. is it possible to append some data on a text output file appending the data to each row, and without use too much computational I/O ??

Instead of the classical way:

  1. VARX VARY VARZ...
  2. year1 x1 y1 z1
  3. year2 x2 y2 z2
.. I would like to use the much more redeable:

  1. year1 year2 ..
  2. VARX x1 x2 ...
  3. VARY y1 y2 ...
  4. VARZ z1 z2 ...
  5. ...
where the 1,2 series are wroted on different times.. a sort of a appendByRow() function.. and I would avoid of load the whole file in memory and then printing it line-by-line..

is it possible ??
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: [C++] append() to each row of a text file

 
0
  #2
Oct 16th, 2007
>I would avoid of load the whole file in memory and then printing it line-by-line..
Read a line, process it, and write it to a temporary file. Then delete the original file and rename the temporary.

>is it possible ??
It's hard to say. You talk about appending to a row, but your description of the desired result suggests that you want to transpose a matrix, which makes your storage and performance requirements more difficult to meet.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3976 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC