Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
VCL
8-Byte Alignment
Action Classes
Additional Controls
Core VCL Classes
Streaming
TApplication
TApplicationEvents
TCollection
TControl
TForm
TFrame
TList
TScreen
TThread
TWinControl
TypeInfo
DFM to TEXT
Dialog Controls
Docking
Drag/Drop
Emulation Classes
Exceptions
Gestures
Graphics
MAPI Support
MDI Support
Multi-Monitor Support
OnGesture event
Printing
Property/Type Editors
Registry / INI Objects
Ribbon Controls
Sample Controls
Services
Standard Controls
Styles
System Controls
Thread support
Touch Controls
Type Info
Win 3.1 Controls
Win 32 Controls
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/VCL/Core VCL Classes
[ Add a report in this area ]
Report #:
2886
Status:
Closed
CommaText considers space to be a delimiter too
Project:
Delphi
Build #:
7.0.4.453
Version:
7.0
Submitted By:
Rod Rishworth
Report Type:
Basic functionality failure
Date Reported:
11/11/2002 5:34:24 AM
Severity:
Infrequently encountered problem
Last Updated:
3/20/2012 2:24:39 AM
Platform:
All versions
Internal Tracking #:
156894
Resolution:
As Designed
(Resolution Comments)
Resolved in Build:
:
7.0.8.1
Duplicate of:
None
Voting and Rating
Overall Rating:
(14 Total Ratings)
4.36 out of 5
Total Votes:
None
Description
Line 4452 of D7 Classes (SetDelimitedText) reads:
while (P^ > ' ') and (P^ <> Delimiter) do
This should be >= instead (also at a few other points, space is included)
That the control characters split the line OK, but a quote should only be required when there is a risk of a comma in the string.
Steps to Reproduce:
1. Open Excel
2. Set cell A1: Borland Delphi
3. Set cell B1: 7
4. Save as 'C:\CSV.CSV'
5. Close Excel (btw, Excel is just an example)
6. CSV.CSV has one line: Borland Delphi,7 - note no quotes, but clearly two fields
7. Open Delphi, run the following code:
var
CSV: TStringList;
Line: TStringList;
begin
CSV := TStringList.Create;
Line := TStringList.Create;
CSV.LoadFromFile('C:\CSV.CSV');
Line.CommaText := CSV[0];
8. Observe that Line.Count = 3 and Line[1] = 'Delphi', not '7' as hoped.
Workarounds
None
Attachment
None
Comments
Stefan Hoffmeister at 11/11/2002 9:35:51 AM
-
The CSV file is not attached.
wayne hubbard at 11/18/2002 3:13:44 AM
-
omg, he *tells* you how to make it
does bor(g)land want *everything* on a silver platter???
Robert Cram at 3/6/2003 11:50:05 PM
-
Although I agree that it's a pain, it's probably as designed. The helpfile states:
Note: CommaText is the same as the DelimitedText property when Delimiter is ',' and QuoteChar is '"'.
Spaces and commas that are not contained within double quote marks are delimiters. Two commas next to each other will indicate an empty string, but spaces that appear next to another delimiter are ignored. For example, suppose CommaText is set to:
"Stri,ng 1", "Stri""ng 2" , String 3,String4
The list will then contain:
Stri,ng 1
Stri"ng 2
String
3
String4
Kevin Davidson at 3/25/2003 9:05:49 AM
-
The described behavior is exactly what the help file says it should do:
"When assigning CommaText, the value is parsed as SDF formatted text. For SDF format, strings are separated by commas OR SPACES".
This is not a bug.
Nick Hodges at 6/21/2007 10:00:04 PM
-
I use these two little functions to get around this:
function DoubleQuotedString(aString: AnsiString): AnsiString;
begin
Result := Format('"%s"', [aString]);
end;
function ProcessPath(aPath: AnsiString; aDelimiter: AnsiChar): AnsiString;
begin
Result := DoubleQuotedString(StringReplace(aPath, aDelimiter, DoubleQuotedString(aDelimiter), [rfReplaceAll]));
end;
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us