LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   [C++] append to each row of a text files (https://www.linuxquestions.org/questions/programming-9/%5Bc-%5D-append-to-each-row-of-a-text-files-592246/)

sylvaticus 10-16-2007 09:10 AM

[C++] append to each row of a text files
 
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:

Code:

      VARX    VARY      VARZ...
year1  x1        y1        z1
year2  x2        y2        z2

.. I would like to use the much more redeable:

Code:

      year1    year2 ..
VARX    x1      x2 ...
VARY    y1      y2 ...
VARZ    z1      z2 ...
...

where the 1,2 series are wrote 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 ??

graemef 10-17-2007 04:36 AM

To achieve that you will need to read in the entire file append the data to each line before writing it back out again, so no simple solution, compared with appending the new year to the end of the file.

ta0kira 10-18-2007 07:22 AM

Is this a one-time task? Do you just have one file to transpose or are you needing to create a program which will maintain this matrix?
ta0kira


All times are GMT -5. The time now is 07:47 AM.