View Revisions: Issue #28582

Summary 0028582: CSV import into StringGrid omits first line
Revision 2015-08-28 22:49 by wp
Steps To Reproduce The attached demo project shows the issue with the current version of Lazaraus, and it can be used to verify the improvements due to this patch.

Several data files are provided for the test; all of them contain 5 data lines like in the example above.

"NoHeader_0.txt" - no header line, data start immediately at the top
"NoHeader_1.txt" - no header line, 1 additional line to be ignored above the first data line
"NoHeader_2.txt" - no header line, 2 additional lines to be ignored above the first data line
"Header_0.txt" - a header line immediately at the top, data lines follow
"Header_1.txt" - one line to be ignored, then the header line, then the data lines
"Header_2.txt" - two lines to be skipped, then the header line, then the data lines

The demo program contains a combobox for selecting one of these input files. The parameter "WithHeaders" of the grid's method "LoadFromCVSFile" is set according to the state of the checkbox "File with headers". In addition, the combobox "Skip..." allows to skip no, one or two data lines above the imported lines (used by the patched version only!)

To reproduce the described behavior and the screenshot, load the file "NoHeader_0.txt" and uncheck the "WithHeaders" box.
In addition, load "No_Header_1.txt" or "NoHeader_2.txt" --> the dummy lines are imported as well which is not expected.
Load "Header_1.txt" with "File with Header" checked --> the predefined headers of the upper grid are partly overwritten by the dummy text, the headers of the lower grid (no predefined headers) are not detected correctly as well.

Apply the patch and repeat the tests. The patch introduces an additonal (optional) parameter "SkipLines" to the "LoadFromCSVFile" method which can be selected in the gui by means of the "Skip..." combobox.

Whenever the parameters selected by "File with header" and "Skip..." match the structure of the file the data are corrected imported.
Revision 2015-08-28 22:44 by wp
Steps To Reproduce The attached demo project shows the issue with the current version of Lazaraus, and it demonstrates also the improvements due to this patch.

Several data files are provided for the test; all of them contain 5 data lines like in the example above.

"NoHeader_0.txt" - no header line, data start immediately at the top
"NoHeader_1.txt" - no header line, 1 additional line to be ignored above the first data line
"NoHeader_2.txt" - no header line, 2 additional lines to be ignored above the first data line
"Header_0.txt" - a header line immediately at the top, data lines follow
"Header_1.txt" - one line to be ignored, then the header line, then the data lines
"Header_2.txt" - two lines to be skipped, then the header line, then the data lines

The demo program contains a combobox for selecting one of these input files. The parameter "WithHeaders" of the grid's method "LoadFromCVSFile" is set according to the state of the checkbox "File with headers". In addition, the combobox "Skip..." allows to skip no, one or two data lines before the import (used by the patched version only!)

To reproduced the described behavior and the screenshot, load the file "NoHeader_0.txt" and uncheck the "WithHeaders" box.
Load "No_Header_1.txt" or "NoHeader_2.txt", the dummy lines are imported as well which is not expected.
Load "Header_1.txt" with "File with Header" checked, the predefined headers of the upper grid are partly overwritten by the dummy text, the headers of the lower grid (no predefined headers) are not detected correctly as well.

Apply the patch and repeat the tests. The patch introduces an additonal (optional) parameter "SkipLines" to the "LoadFromCSVFile" method which can be selected in the gui by means of the "Skip..." combobox.

Whenever the parameters selected by "File with header" and "Skip..." match the structure of the file the data are corrected imported.