If the file contains a file that is not a. csv file
Source: Internet
Author: User
Expand a file from the file that is not a. csv file. I am afraid that the extension name will be changed by others, or will the installation contain commas (,), because some files read garbled content? As a result, it reads garbled characters as commas? However, the rigorous methods and theories of the .csv file cannot be taken for granted. In fact, simply adding a comma is definitely not a. csv file.
Expansion is not allowed here. Fear that others will change the expansion name
Does the installation contain commas (,), because some files read garbled content? As a result, it reads garbled characters as commas?
However, the rigorous methods and theories of the .csv file cannot be taken for granted. In fact, it is not rigorous to press the comma only. In fact, garbled characters may be changed to commas. the second file contains a comma, which is a qualified csv file.
Thank you!
------ Solution --------------------
No way
------ Solution --------------------
Try str_getcsv parsing
Http://php.net/manual/en/function.str-getcsv.php
Judge by error
------ Solution --------------------
In no case will garbled characters be caused by reading commas
Csv files are text files. the only recognizable place is that each line has an equal number of column delimiters (by default, comma)
Considering that the content may contain commas (,), when the number of column delimiters in more than 80% rows is detected to be equal, it can be considered as a qualified csv file.
In addition, non-standard csv, that is, the content of the character type is not enclosed by double quotation marks. At least php5.3 for win is unavailable
The fgetcsv or str_getcsv function is correctly read.
------ Solution --------------------
Csv files express an array
If the number of columns in each row is different, it is not csv
------ Solution --------------------
Full name
Comma Separated Values
Edit this section
Rules
1 is not left blank, in the unit of action.
2. the column name can be included or not included. the column name is the first row of the file.
Three rows of data are not broken, and there are no empty rows.
4. use a comma (,) as the separator. if the column is empty, its existence must be indicated.
If the five columns contain commas (,), enclose the field value with quotation marks.
If the six columns contain quotation marks ("), they should be replaced with double quotation marks (" ") for escape, and the field value should be included with the quotation marks.
7. quotation marks are used to read and write files.
8 Internal code format is not limited, can be ASCII, Unicode or other.
9 special characters are not supported
------ Solution --------------------
Query according to rules
------ Solution --------------------
What format do you want your csv file to be in? In addition, for files, there is no garbled concept, only the concept of bytes,
Garbled characters are only a few bytes that cannot be displayed in the specified character set (such as GB2312.
------ Solution --------------------
Use commas (,) as the separator. if the column is empty, its existence must be expressed.
This is important.
------ Solution --------------------
If you find a class in other formats that can be imported into a csv file, you cannot do it. this curve saves the country.
------ Solution --------------------
Discussion
Reference:
Use commas (,) as the separator. if the column is empty, its existence must be expressed.
This is important.
I told you everything. isn't that true?
If a word contains a comma, do you know whether the comma is a delimiter or a valid character?
You can read a. csv file by phone number.
However, you only need to use commas (,) to distinguish between them. Csv files are too far-fetched. Too many reasons
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.