
April 1st, 2008 by

daniva

Loading ...
You’d like to have a script read through the file, toss out all the lines that begin with Success, and then save the file, a file which will then hold only information about the operations that failed.

April 1st, 2008 by

daniva

Loading ...
Although we can’t directly search and replace text inside a text file, we can do the next best thing. We can: 1) open up a text file; 2) read the text into a variable; 3) do a search-and-replace on that variable; and 4) re-save the text file. We can even do all that from the command line, although we’ll hold off on that for a moment. Instead, let’s start with a simple script that carries out the search and replace:

April 1st, 2008 by

daniva

Loading ...
CSV is short for comma-separated-values file, a text file in which individual elements separated by commas. For example, say you have a CSV file consisting of user first names, last names, and job titles; that file might look something like this:

April 1st, 2008 by

daniva

Loading ...
Suppose we have a text file – left over from a previous column – that consists of a bunch of names…

April 1st, 2008 by

daniva

Loading ...
ForReading and ForWriting – that we’ll use when working with our text file.

April 1st, 2008 by

daniva

Loading ...
To combine File1.log and File2.log into a single file (which we’ll call Output.txt) we’ll have to first read File1.log and append the contents of that file to output.txt, then we’ll have to read File2.log and append the contents of that file to Output.txt.

April 1st, 2008 by

daniva

Loading ...
What you’re looking for is a script that can read through the file and report the number of occurrences for each item; in other words, a script that can return a report…

April 1st, 2008 by

daniva

Loading ...
Reading the last line of a file is a workaround. There is no script that reads just the last line of a text file. But here’s a script that will make it look like you read just the last line of a text file:

April 1st, 2008 by

daniva

Loading ...
Is it important that your text files be formatted like this? It’s not just important, it’s crucial. We’re going to use database techniques to retrieve information from the file, and to do that the file needs to be delimited in some way (in this case, using the comma as the delimiter). Ideally, your files should include a header row as well. As long as your text file looks like this.

April 1st, 2008 by

daniva

Loading ...
When you create a new Function Library and save it to your hard disk, the files are saved in Unicode. i have found out that, when i was trying to load an entire library file dynamically

April 1st, 2008 by

daniva

Loading ...
the first thought is to use the InStr function to see if the word “Error” appears anywhere in each line of the log file; you could then keep a running tally of the number of times you found the word, a technique remarkably similar to the one we demonstrated in yesterday’s column. That was a good idea, but, as you discovered, there was one major flaw in the plan: technically your log file has only one line in it. Consequently, your script always reported that it found one instance of the word Failure, regardless of how many instances actually existed. “But I’m stuck,” you wrote, “because there’s no way to break this single line into multiple lines.”

April 1st, 2008 by

daniva

Loading ...
The FileSystemObject is extremely useful, but it also has its limitations; one of the major limitations is the fact that it can only read a file from top to bottom. Unlike, say, the Tail utility, you can’t ask the FileSystemObject to read a file from the bottom up.

April 1st, 2008 by

daniva

Loading ...
The FileSystemObject is extremely useful, but it also has its limitations; one of the major limitations is the fact that it can only read a file from top to bottom. Unlike, say, the Tail utility, you can’t ask the FileSystemObject to read a file from the bottom up.

April 1st, 2008 by

daniva

Loading ...
You don’t need Microsoft Word just to print a few text files. Instead, you can use the Shell object – which is built right into the operating system – to print text files. And what’s cool about this is the fact that you can print these files even though the Shell object doesn’t have a Print method.
Recent Comments