||Re: character string problem
Mervyn Bick <email@example.com>
||Sun, 17 Mar 2019 18:22:46 +0200
On 2019-03-17 3:54 PM, Charlie wrote:
> Hi Mervyn.. It is possible that I have some single quotes but probably not as many. Although sometimes they describe passenger cars by feet (') also. I was wondering if you could use ^ or | to enclose. I think I have seen them before. Although I believe they replaced the comma. Isn't the comma the delimiter and ( ") the enclosure? I'm confused. If you use copy to file with ^ it changes the comma.
The dBASE command COPY TO ... DELIMITED produces a comma separated file.
If you want anything other than a comma to separate the field values
(for example TAB or | ) you would have to write your own code to produce
the file. It isn't particularly difficult but this has been addressed
in usvout.prg in the dUFLP anyway so you wouldn't actually have to
reinvent the wheel if you ever need this. :-)
A delimiter is used to wrap text values. The default delimiter used
with COPY TO ... DELIMITED is a double quote. The delimiter can,
however be changed by specifying it in the command e.g COPY TO ...
DELIMITED WITH ' or COPY TO ... DELIMITED WITH ^ These commands
willchange the delimiters but not the separators.
Although dBASE can change the delimiter to any printable character not
many other programs can handle anything except a single quote or a
double quote as a delimiter. SQL normally requires a single quote but
some SQL servers such as MySQL and Firebird will accept double quotes.
As far as I know there is no way to use any other character as a
delimiter in SQL.
If you use double quotes as delimiters then any double quote in a text
literal must be escaped. If you use single quotes as delimiters than
any single quote in a text literal must be escaped.
Using double quotes as the delimiters and escaping any double quotes in
the text means you can ignore any single quotes used as apostrophes or
as a symbol for feet in the text.
> I believe the program you attached is not complete. It seems to end abruptly.
If you look at the code you will see it creates tmaster.csv (or rather
it is supposed to :-) ) and then stops. You could perhaps add
msgbox('Done') at the end if you want a less abrupt ending.
The proof of the pudding ...... Did the little program produce a
version of tmaster.csv? If it did, did it "escape" double quotes in
part_no and au_desc by adding a \ in front of them? Could you upload
tmaster.csv to MySQL?