CSV file is generally "," as a delimiter, but now there is a lot of content in the database contains commas, how should this situation be handled?
Reply to discussion (solution)
Also ask this statement error, $rs [' Group_concat (' Concat_ws (' x ', ' sku ', ' quantity-purchased ') ' problem, should be the ' X ' question, how to deal with
echo $rs [' Ship-postal-code ']. ",". $address. ",". $rs [' Recipient-name ']. ",". $rs [' ship-city ']. ",". $rs [' ship-state ']. " , ". $rs [' Buyer-phone-number '].", ". $rs [' Group_concat (Concat_ws (' X ', ' sku ', ' quantity-purchased ')) '." \ r \ n ";
CSV file is generally "," as a delimiter, but now there is a lot of content in the database contains commas, how should this situation be handled? According to the format of the CSV file, when the content contains a comma is the content should be enclosed in double quotation marks, when the content contains double quotation marks, the double quotation marks should be converted into two double quotes, of course, the entire content is enclosed in double quotation marks
In general, the contents of the character type should be enclosed in double quotation marks
Also, the fgetcsv after php5.3 cannot be a recognition of Chinese in double quotes
Also ask this statement error, $rs [' Group_concat (' Concat_ws (' x ', ' sku ', ' quantity-purchased ') ' problem, should be the ' X ' question, how to deal with
PHP Code
echo $rs [' Ship-postal-code ']. ",". $address. ",". $rs [' Recipient-name ']. ",". $rs [' s ...]
$rs [' Group_concat (Concat_ws (' X ', ' sku ', ' quantity-purchased ') ')
Single quotes with single quotes, no mistakes.
Xuzuning Big,
One. Does this problematic statement add an escape character or double quotation marks?
Two. This statement is to write the contents of the database into a CSV file, what should I do??
Three. I Marson from the TXT file, ask the CSV file and TXT file which is not easy to break the problem caused by the delimiter??
The standard CSV is like this
"ABCD", "a" "", 123
The values for the three columns are ABCD, a ", 123, respectively.
Double quotation marks are usually omitted when there is no ambiguity
Aaa,bb,cccc
But if there is a Chinese
AAA, Kanji, 123
So php5.3 can only read 1, 3 columns of content, the 2nd column is empty
You just have to notice the fact that it doesn't matter what tool you use.
Since the tool has become a tool, it naturally has its merits.
$rs [' Group_concat (Concat_ws (' X ', ' sku ', ' quantity-purchased ') ')
How should this statement be changed?? I can't even read the data.
$rs ["Group_concat (Concat_ws (' X ', ' sku ', ' quantity-purchased ')"]
When exporting a file, you can select "Column delimiter (C)" At the bottom, and you can choose tab-delimited, but you will need to note that the delimiter is invalid when the "," symbol appears in the document.