473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Writing to text file

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

Nov 21 '05 #1
5 949
Read in the entire line, append your text and write it to a new file.

"Yunus's Group" <yu*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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

Nov 21 '05 #2
Thanks for the reply,

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

Nov 21 '05 #3

"Yunus's Group" <yu*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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

Nov 21 '05 #4
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's Group" <yu*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks for the reply,

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

Nov 21 '05 #5
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
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Neil Trigger | last post by:
Is there a way of creating a seperate text file on a server every time a form is sent? -- ¿ Trigger ? http://www.magic2k.com/ http://www.oddmap.co.uk
2
by: sp | last post by:
Hello everybody, I have an xml doc and I am trying to write the values from xml file to a tab delimited text file. Currently, what I am doing is I am reading xml file through XpathNavigaotr and...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
3
by: CsharpNewcommer | last post by:
Hi Can someone tell me how to write the data from a TextBox (txt) or Label (lbl) to a text file to be printed. I have read the info from msdn.microsoft.com/library on "Writing Text to a File",...
2
by: Tony | last post by:
Yes, I need to specify a font type so that the characters will be evenly spaced when I write to a tab delimited text file. So how does one specify a font type to write/print and which font is...
0
by: Yunus's Group | last post by:
Yunus's Group May 23, 3:36 pm show options Newsgroups: microsoft.public.dotnet.languages.vb From: "Yunus's Group" <yunusasm...@gmail.com> - Find messages by this author Date: 23 May 2005...
3
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
3
by: sethuganesh | last post by:
hi, i am not able to write a text properly in a text file in vb.net.below is the code that i have written. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As...
5
by: grinder | last post by:
first off, i am an extreme newbie to C. i am an undergrad research assistant and i have been shifted to a project that involves building a fairly involved c program. The part that i am stuck on now...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.