Pro.ID21695 TitleParse Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21695 AC0 Submit0 Ratio- 时间&空间限制描述The CSV ("Comma Separated Value") file format is often used to exchange data between disparate applications. The file format, as it is used in Microsoft Excel, has become a pseudo standard throughout the industry, even among non-Microsoft platforms. The CSV file format in this problem is defined below:
However, fields may contain embedded line-breaks (see below) so a record may span more than one line.
Example: John,Doe,120 any st.,"Anytown, WW",08123
So John , Doe ,... resolves to "John" and "Doe", etc. Space characters can be spaces, or tabs.
In the above example. "Anytown, WW" has to be delimited in double quotes because it has an embedded comma.
So, John "Da Man" Doe would convert to "John ""Da Man""",Doe, 120 any st.,...
So: Field 1: Conference room 1 can be converted to: Conference room 1, "John, Note that this is a single CSV record, even though it takes up more than one line in the CSV file. This works because the line breaks are embedded inside the double quotes of the field.
So, to preserve the leading and trailing spaces around, the last name above: John ," Doe ", ...
The delimiters will always be discarded. Your task is to write a program as a CSV parser which can parse the input CSV file correctly. 输入Your program should read the content of input file and parse it according to the CSV format described above. Input is ended by EOF. Every field contains no more than 50 characters, and there are at most 500 fields in the input file. 输出Description The CSV ("Comma Separated Value") file format is often used to exchange data between disparate applications. The file format, as it is used in Microsoft Excel, has become a pseudo standard throughout the industry, even among non-Microsoft platforms. The CSV file format in this problem is defined below:
However, fields may contain embedded line-breaks (see below) so a record may span more than one line.
Example: John,Doe,120 any st.,"Anytown, WW",08123
So John , Doe ,... resolves to "John" and "Doe", etc. Space characters can be spaces, or tabs.
In the above example. "Anytown, WW" has to be delimited in double quotes because it has an embedded comma.
So, John "Da Man" Doe would convert to "John ""Da Man""",Doe, 120 any st.,...
So: Field 1: Conference room 1 can be converted to: Conference room 1, "John, Note that this is a single CSV record, even though it takes up more than one line in the CSV file. This works because the line breaks are embedded inside the double quotes of the field.
So, to preserve the leading and trailing spaces around, the last name above: John ," Doe ", ...
The delimiters will always be discarded. Your task is to write a program as a CSV parser which can parse the input CSV file correctly. Input Your program should read the content of input file and parse it according to the CSV format described above. Input is ended by EOF. Every field contains no more than 50 characters, and there are at most 500 fields in the input file. Output If the input file isn't a legal CSV format file, simply output "Wrong Format" in one line, otherwise you should output all fields. Please output one line-break ('\n') after each field. E.g. suppose the input file is like: field11, field12, …, field1n So the output should actually be like: field11 Note that one field may contain embedded line-breaks, so in the output file one field may occupy several lines. (You can refer to the Sample Input 3 and Sample Output 3 for details). Sample Input Sample Input 1: Sample Output Sample Output 1: Source 样例输入Sample Input 1: 样例输出Sample Output 1: 作者 |