Re: Replace 1st Character On Each Line of a Text File?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You don't have to use an Array. Simply open 2 files, the source file
ForReading and the target file ForWriting. Make a loop that reads each
line from the source, manipulates the first character and directly
writes it to the target file.
When the loop is finished, close both files. Maybe you need to remove
the original source file and rename the targetfile to the same name as
the original source file. (Depends on what you exactly want to
achieve.)


On Thu, 21 Apr 2005 07:45:03 -0700, "Romual Piecyk"
<RomualPiecyk@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>Thanks for the reply. I am actually very familiar with reading and writing
>text files using the FileSystem object. What I can seem to find info on is
>how to do exactly what you described - read a line, make a change to it, then
>rewrite over it.
>
>I thought about taking the file and putting each line into an array, then
>try to rewrite each line with the new text to a new text file, but the array
>would have to be about 600,000 objects large, and I don't know if an array
>can be that big.
>
>
>"WM" wrote:
>
>> Search for FSO - the FileSystem Object. You can easily open a file,
>> read it line by line, and write the value of the line back with
>> changes. You should be able to google up some good examples.
>> 4/20/2005 9:03:02 PM
>> Romual Piecyk <RomualPiecyk@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
>> message
>> <193BB6D1-8684-4F69-9C25-0399E405C816@xxxxxxxxxxxxx>
>>
>> > I need a script that will open and read a text file, and replace
>> the first
>> > character of every line with an X, or whatever other character I
>> choose. Does
>> > anyone have any ideas that can start me in the write direction?
>>

.



Relevant Pages

  • Re: runtime error 9 -- subscript out of range
    ... My source file has 55000 rows and 20 columns. ... Here I want to a put filter and want to paste filtered data in seperate XL. ... Using Do While Loop I am pulling out all 55000 row value in an array (1 ... here when I used single Do while loop XL was causing a problem ...
    (microsoft.public.excel.programming)
  • Re: Writing a simple assembler
    ... preprocessor for) in case I don't have conditional branches and jumps. ... around the main loop. ... I first read the entire source file in a array of ... and dump generated code in an array of instructions. ...
    (comp.arch.embedded)
  • Programming Puzzle
    ... out there,Can SomeOne Solve these Porgramming puzzles. ... Q7 Remove duplicates in array ... Q8 Finding if there is any loop inside linked list. ... merely echoing the actual source file is not ...
    (comp.lang.cpp)
  • Programming Puzzle
    ... out there,Can SomeOne Solve these Porgramming puzzles. ... Q7 Remove duplicates in array ... Q8 Finding if there is any loop inside linked list. ... merely echoing the actual source file is not ...
    (comp.lang.c)
  • Re: DirectX did not copy required file
    ... DirectX cab is missing, skip to install. ... Target file is Version 5.1.2600.0 Source file is Version 5.3.1.902 ...
    (microsoft.public.games)