Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default output to the same line in a Text file?

hi there
How do I output to the same position in a Text file everytime? I want to
dump data for a given Date so I'd like to put it in the same row for that
Date everytime, and so overwrite the existing data in that row?

I'm using the following command:

Write #3, logfactor(dateline, 1), logfactor(dateline, 2),
logfactor(dateline, 3)

'where dateline is today's date in Excel date code e.g. 40010

I want to be able to overwrite the existing data for line 40010 in my text
file, and replace it with new data.

Hope that it clear!!!!
thank you
Bernard.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default output to the same line in a Text file?

If, and it's probably a big if, each line in the text file is always exactly
the same length, you could open the file for Binary access, read through it
until you find the beginning of the line you need and replace that line with
the new data.

Barring that, the easiest way is probably to open the existing file for
input, open a second file for output, then
read a line from it,
test if it is the line your want
if not the line you want, write it to the 2nd file
if it is the line you want, write the new data to the 2nd file
and then just read and write from 1st to 2nd to the end of the 1st.
After that you can KILL the 1st file and name the 2nd one with the original
file name.


"Bernard" wrote:

hi there
How do I output to the same position in a Text file everytime? I want to
dump data for a given Date so I'd like to put it in the same row for that
Date everytime, and so overwrite the existing data in that row?

I'm using the following command:

Write #3, logfactor(dateline, 1), logfactor(dateline, 2),
logfactor(dateline, 3)

'where dateline is today's date in Excel date code e.g. 40010

I want to be able to overwrite the existing data for line 40010 in my text
file, and replace it with new data.

Hope that it clear!!!!
thank you
Bernard.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default output to the same line in a Text file?

Thanks J.
No the lines are different lengths but good thinking. Your idea for using
two files is also good, and workable.
I thought (from recollection of a programming course a long time ago, that
there was a command for output to a record position, but maybe not.
thanks
Bernard.



"JLatham" wrote:

If, and it's probably a big if, each line in the text file is always exactly
the same length, you could open the file for Binary access, read through it
until you find the beginning of the line you need and replace that line with
the new data.

Barring that, the easiest way is probably to open the existing file for
input, open a second file for output, then
read a line from it,
test if it is the line your want
if not the line you want, write it to the 2nd file
if it is the line you want, write the new data to the 2nd file
and then just read and write from 1st to 2nd to the end of the 1st.
After that you can KILL the 1st file and name the 2nd one with the original
file name.


"Bernard" wrote:

hi there
How do I output to the same position in a Text file everytime? I want to
dump data for a given Date so I'd like to put it in the same row for that
Date everytime, and so overwrite the existing data in that row?

I'm using the following command:

Write #3, logfactor(dateline, 1), logfactor(dateline, 2),
logfactor(dateline, 3)

'where dateline is today's date in Excel date code e.g. 40010

I want to be able to overwrite the existing data for line 40010 in my text
file, and replace it with new data.

Hope that it clear!!!!
thank you
Bernard.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Creating Tabbed Delimited Text File - Need help with blankcell output dza7 Excel Discussion (Misc queries) 3 November 5th 09 04:55 PM
Subtotal: Totals line output basic Excel Discussion (Misc queries) 0 March 6th 07 09:28 PM
Output space-delimited file with quotes around text? Sinc Excel Discussion (Misc queries) 1 December 5th 06 11:02 PM
Importing text file with no line delimiters mikewilsonuk Excel Discussion (Misc queries) 4 June 15th 06 06:47 AM
Any way to get around the 240-character line limit on text output? awp Excel Discussion (Misc queries) 3 December 14th 04 11:59 PM


All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"