This project has moved and is read-only. For the latest updates, please go here.

CSV Reader / Writer

Dec 10, 2009 at 5:20 PM

I need to read a CSV file.  Are there any libraries in HydroDesktop that already do this?  I could write a simple reader in a flash, but I want to take advantage of existing code if there's something that handles commas in text fields, etc.

Dec 10, 2009 at 9:07 PM
Edited Jan 21, 2010 at 7:46 PM

I've found various examples out there that provided guidance, and have used this experience to add classes that support the kinds of operations and interaction we want with HydroDesktop.

Dec 10, 2009 at 9:34 PM
<!-- body {margin:8px} .LW-yrriRe {font:normal x-small arial} -->
Currently there is no code in HydroDesktop for reading CSV files. If you are planning to improve the current 'Export to CSV' plugin or add new CSV import functionality, please feel free to modify and extend the code.
Thanks again for your contributions to the HydroDesktop project, we greatly appreciate it.


Dec 16, 2009 at 9:10 PM

I added a CSV reader to the Metadata Fetcher plugin.  I've got some other general utilities in there for database operations, web operations, and communicating with a HydroPortal.  I wonder if these should go in one of the main HydroDesktop libraries....

Jan 14, 2010 at 10:00 PM

I added a CsvFileReader class to Metadata Fetcher.  This should be moved to a general Import/Export library.  In the mean time, check out the class if you need to read csv files.  It supports background worker progress updating if you want to use it.

Jan 21, 2010 at 7:48 PM

A student here is working on the CSV Writer.  I think we should put the CSV readers/writers into one of the core libraries for HydroDesktop.  Where should they go?  How about a HydroDesktop.ImportExport namespace in the HydroDesktop.Data solution?  Or perhaps a separate solution is better?  Please advise.


Jan 21, 2010 at 7:50 PM

Your suggested ImportExport namespace is a good idea. Then we can add additional formats later...

Jan 21, 2010 at 9:19 PM

Yep.  Where should the code go?  Which solution and/or directory? 

Jan 21, 2010 at 9:21 PM

Jiri do you have a suggestion on the best place to put this code?

Jan 21, 2010 at 9:27 PM

My suggestion is:

Solution: hydrodesktop/Source/Libraries/DataAccess/HydroDesktop.Data.sln

Directory: hydrodesktop/Source/Libraries/DataAccess/HydroDesktop.Data/ImportExport

Namespace: HydroDesktop.ImportExport

The CSV import and export methods should be a part of the HydroDesktop.Data.dll assembly.


Jan 21, 2010 at 10:00 PM

Thanks Jiri.  This is done.


Jan 27, 2010 at 11:22 PM

At build 40831, a DelimitedTextWriter was added that is capable of writing text files using a delimiter supplied by the caller, such as a comma, a tab, or a string of characters. The CsvWriter class is now deprecated.  If you are using the CsvWriter class, please switch to the DelimitedTextWriter class.