CSV Reader / Writer

Developer
Dec 10, 2009 at 4: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.

Developer
Dec 10, 2009 at 8:07 PM
Edited Jan 21, 2010 at 6: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.

Coordinator
Dec 10, 2009 at 8:34 PM
<!-- body {margin:8px} .LW-yrriRe {font:normal x-small arial} -->
Tim,
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.
 
Jiri

 

Developer
Dec 16, 2009 at 8: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....

Developer
Jan 14, 2010 at 9: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.

Developer
Jan 21, 2010 at 6: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.

 

Coordinator
Jan 21, 2010 at 6:50 PM

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

Developer
Jan 21, 2010 at 8:19 PM

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

Coordinator
Jan 21, 2010 at 8:21 PM

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

Coordinator
Jan 21, 2010 at 8: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.

 

Developer
Jan 21, 2010 at 9:00 PM

Thanks Jiri.  This is done.

 

Developer
Jan 27, 2010 at 10: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.