Data transfer to text file.

  • Thread starter Thread starter Phoebe.
  • Start date Start date
P

Phoebe.

Hi, Good Day!

I'm writing a program transferring some data to a text file.

Below is the screen that i produced
SecCode A_Before A_After B_Before
B_After
HK0025 BMG2097Z1059 BMG2097Z1471
HK0025
6190336 6616984
HK0106 BMG8086H1051 BMG8086H1135
HK0110 HK0110009476 #N/A Sec
HK0110
6003616 #N/A Sec
HK0121 KYG4586H1092 KYG2099D1025
HK0131 HK0131010099 HK0131012251

I'm checking 2 parts, one is the A, the other is B. If changes made, then
I'll put the data into this text file.
For this 2 parts, beside the normal print(filenumber, data), I've included a
printline(filenumber). So it produce
the screen as shown above.

How can I create a text file as the below screen.

SecCode A_Before A_After B_Before
B_After
HK0025 BMG2097Z1059 BMG2097Z1471 6190336 6616984
HK0106 BMG8086H1051 BMG8086H1135
HK0110 HK0110009476 #N/A Sec 6003616 #N/A Sec
HK0121 KYG4586H1092 KYG2099D1025
HK0131 HK0131010099 HK0131012251

Can someone help?
Thanks in advanced.

rgds,
Phoebe.
 
Is it really necessary to modify the same file? Is it a very large file?
If not, why not create a temporary new file, write the old + new
information to it, delete the old file and rename the temporary file to
the original file name?
 
Antenna,

Thanks for your suggestion.
Is there any other way becoz I found it very troublesome.

I just want the data to be written in one line if both the security code for
A & B are same

Thanks again.

rgds,
Phoebe.
 
Just do what I say :)
You would make it much more difficult. You would have to play with
Seek(), reserve space for the data you would want to write on a line or
you would have to shift all data after the line you're updating. For
example:

line 1: 'AAAA BBBB'
line 2: 'AAA1 BBB2'

Update line 1: 'AAAA BBBB 0000 XXXX'

That means you would have to shift all lines after line1 1 + 4 + 1 + 4
bytes. Or you could reserve 1 + 4 + 1 + 4 bytes in the initial file.
What is so troublesome about creating a temp file? It's the least
troublesome approach. Unless of course you could use binary files. Then
it would be easy to do.
 
* "Phoebe. said:
I'm writing a program transferring some data to a text file.

Below is the screen that i produced
SecCode A_Before A_After B_Before
B_After
HK0025 BMG2097Z1059 BMG2097Z1471
HK0025
6190336 6616984
HK0106 BMG8086H1051 BMG8086H1135
HK0110 HK0110009476 #N/A Sec
HK0110
6003616 #N/A Sec
HK0121 KYG4586H1092 KYG2099D1025
HK0131 HK0131010099 HK0131012251

I'm checking 2 parts, one is the A, the other is B. If changes made, then
I'll put the data into this text file.
For this 2 parts, beside the normal print(filenumber, data), I've included a
printline(filenumber). So it produce
the screen as shown above.

Have a look at 'Write' and 'WriteLine'.
 
Back
Top