Thursday, September 01, 2005
Microsoft LogParser
I downloaded it and gave it a try. Here is a walk through of a test that I did to query a CSV file(s).
The Test
I created a file called Test.csv that contains the following:
TimeStamp, MessageType, Message
2004-03-14 18:56:55, Warning, One
2004-03-14 14:02:23, Information, Two
2004-03-14 14:02:23, Information, Three
2004-03-14 12:00:00, Information, Four
2004-03-14 00:41:47, Warning, Five
2004-03-13 22:17:00, Information, Six
2004-03-13 22:06:48, Information, Seven
2004-03-13 22:06:48, Error, Eight
2004-03-13 12:00:00, Information, Nine
2004-03-12 22:30:47, Information, Ten
I saved the file to the C:\ and then from the command-line I did the following:
C:\Program Files\Log Parser 2.2>logparser "Select * from c:\test.csv"
The result of that was the following:
Filename RowNumber TimeStamp MessageType Message
----------- --------- ------------------- ----------- -------
c:\Test.csv 2 2004-03-14 18:56:55 Warning One
c:\Test.csv 3 2004-03-14 14:02:23 Information Two
c:\Test.csv 4 2004-03-14 14:02:23 Information Three
c:\Test.csv 5 2004-03-14 12:00:00 Information Four
c:\Test.csv 6 2004-03-14 00:41:47 Warning Five
c:\Test.csv 7 2004-03-13 22:17:00 Information Six
c:\Test.csv 8 2004-03-13 22:06:48 Information Seven
c:\Test.csv 9 2004-03-13 22:06:48 Error Eight
c:\Test.csv 10 2004-03-13 12:00:00 Information Nine
c:\Test.csv 11 2004-03-12 22:30:47 Information Ten
Statistics:
-----------
Elements processed: 10
Elements output: 10
Execution time: 0.00 seconds
I then copied the Test.csv file, creating "Copy of Test.csv", and ran the following:
C:\Program Files\Log Parser 2.2>logparser "Select Filename, TimeStamp, MessageType, Message from C:\*.csv where messageType ='Warning'"
The result of that was the following:
Filename TimeStamp MessageType Message
------------------- ------------------- ----------- -------
c:\Copy of Test.csv 2004-03-14 18:56:55 Warning One
c:\Copy of Test.csv 2004-03-14 00:41:47 Warning Five
c:\Test.csv 2004-03-14 18:56:55 Warning One
c:\Test.csv 2004-03-14 00:41:47 Warning Five
Statistics:
-----------
Elements processed: 20
Elements output: 4
Execution time: 0.02 seconds
Conclusion
The idea of being able to query a directory of files is cool.
There is a lot more to LogParser so download it an give it a try.
I also found an artical on using the LogParser DLL in a VBScript "All You Need is Log (Well, Log Parser)".
Thursday, August 25, 2005
Floating-Point Numbers
I have been working with floating-point numbers. Floating-point numbers are not exact in computers, they are numbers that closely represent a decimal number.
See the following URL’s for more information floating-point numbers.
www.lahey.com/float.htm
www.codeproject.com/dotnet/ExtremeFloatingPoint1.asp
www2.hursley.ibm.com/decimal/decifaq1.html
Here are some things that I found quite surprising.
1) In Microsoft Excel, enter the following into a cell.
=(0.5 - 0.4 - 0.1)
The result should be 0, however it is actually -2.77556E-17.
2) I created a C# windows applications and dropped a button onto the form and then added the following code to the button’s click event.
double f = Convert.ToDouble("1000000000.12345678901");
MessageBox.Show(f.ToString("0.0000000000000000"));
f = f - 1000000000;
MessageBox.Show(f.ToString("0.0000000000000000"));
When you run the application you will get the following message boxes:
1) 1000000000.1234600000000000
2) 0.1234568357467650
You would expect that the number displayed in the second message box would be 0.12346 because that is what the fractional part is after the initial assignment of the f variable. But it turns out that after you subtract 1 billion, something happens to cause the numbers at the end to appear.
Wednesday, August 17, 2005
Geek Joke
I read this awhile ago. And, the more I think about it, the funnier it becomes. It is funny because it’s true. Then, if you step back from it, it is just plain funny and clever.
From Coding Horror:
A Software Engineer, a Hardware Engineer and a Departmental Manager were on their way to a meeting in Switzerland. They were driving down a steep mountain road when suddenly the brakes on their car failed. The car careened almost out of control down the road, bouncing off the crash barriers, until it miraculously ground to a halt, scraping along the mountainside. The car's occupants, shaken but unhurt, now had a problem: they were stuck halfway down a mountain in a car with no brakes. What were they to do?
"I know", said the Departmental Manager, "Let's have a meeting, propose a Vision, formulate a Mission Statement, define some Goals, and by a process of Continuous Improvement find a solution to the Critical Problems, and we can be on our way."
"No, no", said the Hardware Engineer, "That will take far too long, and besides, that method has never worked before. I've got my Swiss Army knife with me, and in no time at all I can strip down the car's braking system, isolate the fault, fix it, and we can be on our way."
"Well", said the Software Engineer, "Before we do anything, I think we should push the car back up the road and see if it happens again."
Sunday, August 07, 2005
Mashups
I have been listing to some Mashups from www.MashupTown.com. These are awesome peaces of arts. If you have never listened to a Mashups before check out some of my favorites listed below.
Gotta Make Betty Sweat
Sharp dressed party
Bootystition
Spending one of these nights with Kelly
Stairway to Bootleg Heaven
Wednesday, June 08, 2005
VBScript - Add a file to iTunes
Rab dropped a comment on my iPodder VBScript(Copy New PodCast to My SD Card) post with an example of how to adding a file to iTunes. After looking at his script, I thought it might be cool to see if I could create a Playlist in iTunes and then add the file.
001 ' Variables
002 dim iTunes, FullPath, playlist
003
004 FullPath = "C:\Music\Machups\wewillrockbeverlyhills.mp3"
005
006 ' Connect to iTunes app
007 set iTunes = CreateObject("iTunes.Application.1")
008
009 ' Create playlist
010 set playlist = iTunes.LibrarySource.Playlists.ItemByName("My Test")
011 if playlist is Nothing then
012 iTunes.CreatePlaylist("My Test")
013 set playlist = iTunes.LibrarySource.Playlists.ItemByName("My Test")
014 end if
015
016 ' Add file to playlist
017 playlist.AddFile(FullPath)
018
019 set iTunes = Nothing
020 set playlist = Nothing
Line 10 tries to get a reference to a Playlist called “My Test”. If the Playlist does not exist the playlist variable will be Nothing. If the playlist variable is Nothing, “My Test” Playlist will be created (line 12) and on line 13 the playlist variable will get a reference to the newly created Playlist. Then on line 17 the mp3 file is added to that Playlist.
Friday, June 03, 2005
Google-fu
Also, Engadget has a cool article on how to customize a Google map.