Writing to text file

  • Thread starter Thread starter Yunus's Group
  • Start date Start date
Y

Yunus's Group

Hello,

I have a need to write to a TEXT file which has the columns of data
separated by a tab. I want to add another column as the last column in
the file and add values to all the lines of data in the text file for
that column.

For example: Here is the sample data

EMP_ID EMP_NAME
1 a
2 b

NOW I WANT TO ADD ANOTHER COLUMN GENDER:

EMP_ID EMP_NAME GENDER
1 a M
2 b F
 
Thanks for the reply,

Is there a way to write to the same file? instead of creating a new
file?
 
Yunus's Group said:
Thanks for the reply,

Is there a way to write to the same file? instead of creating a new
file?

Read the file into an Array,
close the file
reopen the file for writing
write the file (Over-writes the file)
close the file
 
Not really. Ever notice that when you're editing an MS Word doc that
there's a temp file created?

You just have to a bit with renaming the file afterwards. You could just
overwrite the file after reading in the info as noted in the other posting,
but then you run the risk of losing the original data if the something goes
wrong with the write.

Jerry
 
Yunus,
Is there a way to write to the same file? instead of creating a new
file?

No never with a textfile, therefore databases are invented. In the beginning
they were as primitive as you describe it.

I hope this helps,

Cor
 
Back
Top