View Issue Details

IDProjectCategoryView StatusLast Update
0034435FPCDatabasepublic2019-12-06 10:39
ReporterwpAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionreopened 
Product VersionProduct Build 
Target VersionFixed in Version3.3.1 
Summary0034435: TCSVDataset file not readable
DescriptionRecently, TCSVDataset was added to the Lazarus component palette which makes it a very visible component.

TCSVDataset inherits from TBufDataset, and this stores its data in the binary file introduced by TBufDataset. This is very confusing to the user because everybody expects the file format to be CSV. I am aware that there are additional methods LoadFromCSVFile/Stream and SaveToCSVFile/Stream. But these files are not the files in which data are stored automatically.
Steps To ReproduceRun attached demo. The project creates some fields and populates them. When the program terminates data are stored automatically to the file specified.

When the program is started a second time an index-out-of-range error is reported.
TagsNo tags attached.
Fixed in Revision43644
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

wp

2018-10-19 12:21

reporter  

csvdataset.zip (2,504 bytes)

wp

2019-12-05 12:39

reporter   ~0119623

Ping (just stumbled across this issue again...)

Michael Van Canneyt

2019-12-05 15:02

administrator   ~0119626

Fixed, thanks for reminding me!

wp

2019-12-05 16:04

reporter   ~0119628

Thanks. It makes the file written by the first run readable in the following runs. After the first run, however, the new code adds a row "Column1,Column2,..." to the top of the csv file, and this is repeated with every subsequent run.

after 1st run:
FirstName,LastName,City,Address,Birthdate
Walter,Mellon,Oklahoma City,"1261, Main Street",01.01.1980
Mario,Speedwagon,Hollywood,"1500, Hollywood Blvd",17.12.1982
Anna,Mull,Los Angeles,"2202, Capitol Square",17.12.1982

after 2nd run:
Column1,Column2,Column3,Column4,Column5
FirstName,LastName,City,Address,Birthdate
Walter,Mellon,Oklahoma City,"1261, Main Street",01.01.1980
Mario,Speedwagon,Hollywood,"1500, Hollywood Blvd",17.12.1982
Anna,Mull,Los Angeles,"2202, Capitol Square",17.12.1982

after 3rd run:
Column1,Column2,Column3,Column4,Column5
Column1,Column2,Column3,Column4,Column5
FirstName,LastName,City,Address,Birthdate
Walter,Mellon,Oklahoma City,"1261, Main Street",01.01.1980
Mario,Speedwagon,Hollywood,"1500, Hollywood Blvd",17.12.1982
Anna,Mull,Los Angeles,"2202, Capitol Square",17.12.1982

Michael Van Canneyt

2019-12-05 16:10

administrator   ~0119629

I noticed that while testing, but that's because you didn't set 'firstlinehasfieldnames' in CSVOptions.
Set that to true and all will be well.

wp

2019-12-05 16:42

reporter   ~0119630

Sure. But still... The file was written by CSVDataset, and it wrote it including titles although FirstLineHasFieldNames was off. Then for reading, FirstLineHasfieldNames must be switched on. No - something's missing here.

Michael Van Canneyt

2019-12-05 17:18

administrator   ~0119631

Committed a fix in 43649. Opening/Closing now uses the same set of options.
It was a subtle bug, because the destroy triggers the close, causing CSVOptions to be freed before it can be used in writing :(

wp

2019-12-06 10:39

reporter   ~0119655

Thanks. Perfect now.

Issue History

Date Modified Username Field Change
2018-10-19 12:21 wp New Issue
2018-10-19 12:21 wp File Added: csvdataset.zip
2018-10-19 12:28 wp Steps to Reproduce Updated View Revisions
2018-10-19 12:29 wp Assigned To => Michael Van Canneyt
2018-10-19 12:29 wp Status new => assigned
2018-10-19 12:29 wp Description Updated View Revisions
2019-12-05 12:39 wp Note Added: 0119623
2019-12-05 13:55 Michael Van Canneyt Project Lazarus => FPC
2019-12-05 15:02 Michael Van Canneyt Status assigned => resolved
2019-12-05 15:02 Michael Van Canneyt Resolution open => fixed
2019-12-05 15:02 Michael Van Canneyt Fixed in Version => 3.3.1
2019-12-05 15:02 Michael Van Canneyt Fixed in Revision => 43644
2019-12-05 15:02 Michael Van Canneyt FPCTarget => 3.2.0
2019-12-05 15:02 Michael Van Canneyt Note Added: 0119626
2019-12-05 16:04 wp Status resolved => feedback
2019-12-05 16:04 wp Resolution fixed => reopened
2019-12-05 16:04 wp Note Added: 0119628
2019-12-05 16:10 Michael Van Canneyt Status feedback => resolved
2019-12-05 16:10 Michael Van Canneyt Resolution reopened => fixed
2019-12-05 16:10 Michael Van Canneyt Note Added: 0119629
2019-12-05 16:42 wp Status resolved => feedback
2019-12-05 16:42 wp Resolution fixed => reopened
2019-12-05 16:42 wp Note Added: 0119630
2019-12-05 17:18 Michael Van Canneyt Status feedback => resolved
2019-12-05 17:18 Michael Van Canneyt Note Added: 0119631
2019-12-06 10:39 wp Status resolved => closed
2019-12-06 10:39 wp Note Added: 0119655