View Issue Details

IDProjectCategoryView StatusLast Update
0003192JEDI VCL00 JVCL Componentspublic2005-11-26 04:26
ReporterbatonikAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.10 
Summary0003192: JvCsvData: ProcessCsvHeaderRow(): invalid handling of columns with options ("name:options")
DescriptionWhen opening a CSV file, procedure InternalInitFieldDefs() is called (in InternalOpen()) which sets up "FieldDefs" list. A field name is extracted from the form "<NAME>[:OPTIONS]" and added to "FieldDefs".
Then, in ProcessCsvHeaderRow() procedure, options are not stripped from column's name so that a call "FCsvColumns.FindByName(...)" returns nil and an exception is raised.
Since "options" in column names are pretty handy (but I found them while reading source files ;) - I've attached a patch :)
TagsNo tags attached.

Activities

2005-09-12 07:22

 

JvCsvData.patch (880 bytes)
--- JvCsvData.pas	2005-09-12 15:05:14.997239008 +0200
+++ JvCsvData_fixed.pas	2005-09-12 15:05:15.075227152 +0200
@@ -3687,6 +3687,7 @@
   PtrCsvColumn: PCsvColumn;
   CsvFieldName: string;
   ColNum, I: Integer;
+  Pos1: Integer;  //[2005-09-12] -- TP
 begin
   if not ValidateHeaderRow then
   begin
@@ -3707,6 +3708,13 @@
     // Get a string in the format COLUMNAME:Options
     CsvFieldName := StrEatWhiteSpace(GetCsvRowItem(@CsvFieldRec, ColNum));
 
+    //[2005-09-12] by Tomasz Poradowski (tomasz.poradowski@roner.pl)
+    //BUGFIX: we need to strip options from column names, so that
+    //  FCsvColumns.FindByName() can find the real column
+    Pos1 := Pos(':', CsvFieldName);
+    if (Pos1 > 0) then
+      CsvFieldName := Copy(CsvFieldName, 1, Pos1 - 1);
+
     if CsvFieldName = '' then
       JvCsvDatabaseError(FTableName, RsEErrorProcessingFirstLine);
 
JvCsvData.patch (880 bytes)

batonik

2005-09-12 07:28

reporter   ~0007927

I've forgotten to say that this patch is for the latest CVS version of JvCsvData.pas - 1.108.

obones

2005-11-26 04:26

administrator   ~0008159

This is now fixed in CVS. Thanks for the patch, it made my life much easier as the file had evolved a bit in between.

Issue History

Date Modified Username Field Change
2005-09-12 07:22 batonik New Issue
2005-09-12 07:22 batonik File Added: JvCsvData.patch
2005-09-12 07:28 batonik Note Added: 0007927
2005-11-22 09:32 obones Status new => assigned
2005-11-22 09:32 obones Assigned To => obones
2005-11-26 04:26 obones Status assigned => resolved
2005-11-26 04:26 obones Resolution open => fixed
2005-11-26 04:26 obones Note Added: 0008159