Writing to text file

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
 
Y

Yunus's Group

Thanks for the reply,

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

Hal Rosser

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
 
R

Rlrcstr

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
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top