Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Creating Tabbed Delimited Text File - Need help with blankcell output | Excel Discussion (Misc queries) | |||
Subtotal: Totals line output | Excel Discussion (Misc queries) | |||
Output space-delimited file with quotes around text? | Excel Discussion (Misc queries) | |||
Importing text file with no line delimiters | Excel Discussion (Misc queries) | |||
Any way to get around the 240-character line limit on text output? | Excel Discussion (Misc queries) |