LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-16-2007, 09:10 AM   #1
sylvaticus
Member
 
Registered: Apr 2006
Posts: 49

Rep: Reputation: 15
Cool [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 ??
 
Old 10-17-2007, 04:36 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 10-18-2007, 07:22 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
  


Reply

Tags
c++, file, text


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I append text to a string in a file HGeneAnthony Linux - Newbie 4 03-01-2007 12:16 PM
sed script to append variable text gmartin Linux - General 4 12-27-2006 04:44 PM
quickly append text to file blackzone Linux - General 3 09-07-2006 05:48 AM
Delete the first row from a text file loopoo Linux - Newbie 2 08-15-2006 02:57 AM
batch append string to the end of a determined line in text files osio Programming 6 06-30-2005 09:28 AM


All times are GMT -5. The time now is 05:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration