Portable and Efficient Generic Parser for CSV

I recently had some pretty ugly CSV files to parse and decided to have a quick look around to see if there were any libraries around that would handle the specifics of these particular CSV files without me having to write yet another CSV parsing class.  I found a couple that seemed to fit the bill on Code Project and I downloaded them both.  The two specific ones that I looked at were Sebastien Lorien’s Fast CSV Reader and Andrew Rissing’s Generic Parser.  The first one I tried was the Fast CSV Reader since it had some nice looking performance metrics on the Code Project page.  Unfortunately, it blew up on the first file and I decided to give the other parser a try rather than trying to debug why Fast CSV Reader choked. 

I next tried the Generic Parser and it handled the file and even managed to return me just my specific data and skipped all the miscellaneous comments and headers in the CSV files using just the default settings.  On a couple of the CSV files, I made a few tweaks to the default settings of Generic Parser to get the exact data values I needed.  So far, it has performed like a champ.   

There are many CSV parsers out there that are part of larger libraries of utilities and such, but for a quick solution to CSV parsing, I would definitely recommend having a look at Andrew Rissing’s Generic Parser.  I’d love to hear other’s experiences and recommendations for CSV parsing libraries. 

Posted in General .NET, Third Party | Leave a comment

Atlanta Code Camp Demos

Another fantastic Atlanta Code Camp!   Big kudos go out to the crew that threw this together this year in record time and did a fantastic job.  I heard nothing but positive comments from everyone that I talked with.  Big thank you to the sponsors, volunteers, organizers, speakers, and attendees!

I gave two presentations this year: Intro to MEF for Silverlight and Intro to Jounce MVVM Framework for Silverlight. Thanks to the folks that made it out to the talks and especially those of you that stuck with me for both of them.

Here are the links to the slides and code:

Intro to MEF for Silverlight

Intro to Jounce MVVM Framework for Silverlight

(Note that these are zip files with 7z files embedded so you will need to unzip and then “un-7z” them. The files were huge as straight zips and the server wouldn’t let them through as 7z files. 7-Zip is free and will work on both zip/7z files).

Posted in Presentations, Silverlight | Leave a comment

Moving further towards the Dark Side

I’ve been a proponent of dark coding environments for many moons, back to Turbo C++ and that blue.  In fact, my current Visual Studio template started way back in the first version of Visual Studio for .NET. I actually painstakingly hand-copied my colors from HomeSite.   

At the recent Atlanta Code Camp, I overheard someone mention a Visual Studio Theme Editor that goes beyond your personal editing colors and extends into the actual Visual Studio shell (drool).  After a quick look around, I found the Visual Studio Theme Editor and a really great .vstheme file that gets me pretty close to the Expression products. 

Below is what I’m looking at now.  I am a happy man. 

image

Links:

Posted in Visual Studio | Leave a comment

Safari on Windows fail

After years of being nagged to install Safari for Windows by iTunes (every time I update), I finally gave in this morning.  Minutes later, a colleagues emails about a problem he is seeing with a Sharepoint site we use for internal collaboration and that he only sees the issue on Safari on his Mac. 

So, I fire up my brand new Safari for Windows to give the link a try and this is what I see:

clip_image002

 

In fact, no matter how many times I try to launch Safari for Windows, all I get is this AppCrash.  I’m certain there’s an explanation, but I don’t think I care enough to investigate right now.  I’ll likely just un-install it.    

Posted in Uncategorized | Leave a comment

Atlanta Code Camp is open for Registration

Atlanta Code Camp has finally been confirmed for this year and will take place on Saturday. June 25, 2011 at Southern Tech in Marietta, GA.  I’ll be reprising my CodeStock talks on Intro to MEF with Silverlight and Intro to Jounce MVVM Framework for Silverlight.  There are a lot of other really great sessions planned for the day.

Registration for this FREE event is available immediately here.  There is limited space, so you should jump on this right away. 

Posted in Uncategorized | Leave a comment

So long Das Blog, Hello WordPress

I just completed the move from DasBlog to WordPress.  It wasn’t without some bumps, but I did it in one evening.  Since there was no WordPress plug-in that directly supported importing from DasBlog, I was forced to use the RssImporter and then manually clean up all of my old blog posts.  I was very impressed with the ease of installation through my host, WebHost4Life.  So far, I’m enjoying the Admin part of WordPress and I’ve seen no real bumps using LiveWriter to clean the old posts and to post new ones.  I also went ahead and added the Paste as Visual Studio Code Plug-in for LiveWriter and I’m really liking that so far. 

I’m still playing around with themes, so look for that to fluctuate a bit until I find one that I can’t live without. 

Posted in Uncategorized | Leave a comment

Another Great CodeStock!

Once again, CodeStock was awesome and the CodeStock crew took care of everything and made it look easy!  All of the attendees that I had a chance to speak with had nothing but good things to say.  Big thank you to the CodeStock sponsors, volunteers, organizers, speakers, and attendees!

I gave two presentations this year:  Intro to MEF for Silverlight and Intro to Jounce MVVM Framework for Silverlight.  Thanks to the folks that made it out to the talks and especially those of you that stuck with me for both of them.

Here are the links to the slides and code:

Intro to MEF for Silverlight

Intro to Jounce MVVM Framework for Silverlight

(Note that these are zip files with 7z files embedded so you will need to unzip and then “un-7z” them.  The files were huge as straight zips and the server wouldn’t let them through as 7z files.  7-Zip is free and will work on both zip/7z files).

Posted in Presentations, Silverlight | Leave a comment

Happy Beatles Day

In case you didn’t know, The Beatles re-masters are being released today (9/9/9).  Even more exciting is the fact that you will be able to get all of them in mono and in stereo.  So, you can hear them the way they were meant to be heard!!  From my understanding, though, the mono versions will not be released as single CDs.  You’ll have to buy the box set.  The mono box is supposedly “limited edition”, but I would bet anything that in a year, you’ll be able to buy the mono ones without any problem (and mostly likely be able to buy the single discs without dealing with the box set…and find them used at Amazon).  Here’s a really interesting discussion on an Audiophile site about the mono vs. stereo editions.

I think after reading this Audiophile opinion, I am going to buy a couple today at lunch (ok, maybe more than two if they just happen to be sitting there) in stereo as you can’t buy the mono ones (right now) as single CDs.  I’ll grab the mono set at some point when it gets past the “limited edition” status …..though I am dying to hear the earlier albums the way that The Beatles and George Martin created them.  Now, which ones to buy?   Leaning toward Revolver and Abbey Road.  We’ll see what happens when I hit Best Buy to use the $20 gift card that they were so kind to give me for giving them $1000 recently.

Update:  Bought Revolver, Abbey Road, and Sgt. Peppers in stereo.  Revolver sounded so amazing that I went back to the store and bought the Mono box set (the last one!).  All Best Buys are sold out of the Stereo box set.  Got home and started with Please Please Me and I’m at Rubber Soul now.  Wow is all I can say…

Posted in Music | Leave a comment

Prism Presentation – Code and Slides

I recently had the pleasure of speaking at CodeStock 2009 and was very impressed with the conference overall.  The folks behind this conference put in a lot of work and did a really great job.  I got the chance to see some really good presentations as well.  I look forward to attending CodeStock in the future.

The code and slides will be posted soon at the CodeStock site, but I wanted to note a few things about the code that I’m including for those that were present for my talk on Prism.

  1. The AlbumSearch solution included is the one we worked through in the presentation.  In the interest of time, I had skipped the creation of separate olders/namespaces for the Views, ViewModels, etc during the presentation. For the download, I have cleaned that up and placed everything in a much more realistic (cleaner) project structure.
  2. While creating the SearchCommand in the SearchModuleViewModel during the presentation, I had skipped adding a CanExecute handler in the interest of time.  Someone asked me about it later and I promised to provide an example in the download and I have done so.  You’ll notice that the Search button now enables only when there are at least 3 letters typed in the Search Box.  (NOTE:  The only Artist Names defined in my test data are:  Pink Floyd, Mars Volta, and Tool.  Anything
    else will likely blow up as there is no Exception handling in the demo).
  3. During the presentation, I mentioned a much larger solution that goes through each concept of Prism such as Modularity (and the various ways to load Modules), UI Composition, etc.  I have included my PrismConcepts solution in the download as well.
  4. I added a link to a WPF and Silverlight Comparison paper from Wintellect to the Resources slide as promised.

I think that covers it.  Thanks again to the organizers, the sponsors, the presenters, and all the attendees of CodeStock.

Here’s the Code and Slides.                

Posted in Presentations, Prism | Leave a comment

Silverlight UI Rant #2 – ListBoxItem

Tonight’s recipient of my UI Rant is the Silverlight 2 ListBox, or more specifically, the ListBoxItem.  A client recently asked me to provide an alternating row style like the DataGrid for the ListBox.  Now, if you’ve ever tried to add a border or background to your ListBoxItem, you’ve seen this:

DefaultlListBox

No problem, you say, I will simply set the HorizontalContentAlignment of my ListBox to Stretch and all should be good.  When that doesn’t do it, you’ll probably try creating/editing the ListBox’s ItemTemplate….maybe adding a Grid and setting its HorizontalAlignment to Stretch.  This too will fail.

Turns out, the problem is not with your ItemTemplate or even with the ListBox itself.  The issue is in the container that actually contains your Item and that is the ListBoxItem.  The property on the ListBox that allows you to set a custom style for this ListBoxItem is called ItemContainerStyle.  Armed with this information, you quickly throw together a style for your ListBoxItem, maybe like so:

  1. <Style TargetType="ListBoxItem" x:Key="ItemContainerStyle">
  2.     <Setter Property="Padding" Value="3" />
  3.     <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  4.     <Setter Property="VerticalContentAlignment" Value="Top" />
  5.     <Setter Property="Background" Value="Transparent" />
  6.     <Setter Property="BorderThickness" Value="1" />
  7. </Style>

And then add that to your ListBox, like so:

  1. <ListBox Margin="8,8,10,8" x:Name="defaultListBox" ItemsSource="{Binding}"
  2.     ItemTemplate="{StaticResource EmployeeItemTemplate}"  
  3.          ItemContainerStyle="{StaticResource ItemContainerStyle}"/>

Hit F5 and just about the time you congratulate yourself on solving this, the Silverlight Loading Animation will finish and you’ll discover that your ListBox still looks exactly like the original screenshot above.  So, what happened?

What happened is that the default ControlTemplate for the ListBoxItem has its HorizontalAlignment hard-coded to Left and no matter what you do when setting the properties, it will always be Left.  If you’ll do a little diving into the full default style for ListBoxItem, courtesy of SilverlightDefaultStyleBrowser (highly recommended), you’ll see exactly what I’m talking about in the ContentPresenter’s HorizontalAlignment property:

ListBoxItemDefaultStyle

The good news is that because you have the ability to replace the Template of any control in Silverlight, you can simply "correct" this hard-coded problem by replacing the hard-coded Left value for HorizontalAlignment with {TemplateBinding HorizontalContentAlignment}, so your final new Style would look like this:

  1. <Style TargetType="ListBoxItem" x:Key="StretchedItemContainerStyle">
  2.     <Setter Property="Padding" Value="3" />
  3.     <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  4.     <Setter Property="VerticalContentAlignment" Value="Top" />
  5.     <Setter Property="Background" Value="Transparent" />
  6.     <Setter Property="BorderThickness" Value="1" />
  7.     <Setter Property="TabNavigation" Value="Local" />
  8.     <Setter Property="Template">
  9.         <Setter.Value>
  10.             <ControlTemplate TargetType="ListBoxItem">
  11.                 <Grid Background="{TemplateBinding Background}">
  12.                     <VisualStateManager.VisualStateGroups>
  13.                         <!– removed VSM code for brevity  –>
  14.                     </VisualStateManager.VisualStateGroups>
  15.                     <Rectangle x:Name="fillColor" Opacity="0" Fill="#FFBADDE9"   
  16.                        IsHitTestVisible="False" RadiusX="1" RadiusY="1" />
  17.                     <Rectangle x:Name="fillColor2" Opacity="0" Fill="#FFBADDE9"
  18.                        IsHitTestVisible="False" RadiusX="1" RadiusY="1" />
  19.                     <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}"
  20.                        ContentTemplate="{TemplateBinding ContentTemplate}"
  21.                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  22.                        Margin="{TemplateBinding Padding}" />
  23.                     <Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1"
  24.                          StrokeThickness="1" Visibility="Collapsed" RadiusX="1" RadiusY="1" />
  25.                 </Grid>
  26.             </ControlTemplate>
  27.         </Setter.Value>
  28.     </Setter>
  29. </Style>

Now your ListBoxItem will respect the value you are setting for its HorizontalContentAlignment in your Setter above and your ListBox will finally look like this:

CorrectedListBox

Hope that saves someone a little frustration.  I’ll continue on to adding the alternating row style in another post.

Here is the live sample.

Here is the source code.

Posted in Silverlight, UI Rant | Leave a comment