OpenOffice Calc can not read a simple CSV file. Wh

2019-03-01 11:15发布

问题:

I have a Web site (PHP) that generates a CSV file (text/csv) with the following content:

ID;E-Mail_User;Name;Applikation;Rolle;Auftragsdatum;Administrator
522;user@domain;WXDUILAS;ABCD;XYZ;2009-03-04 05:00:09;user@domain

When I select OpenOffice to show the CSV file only an empty spread sheet is shown. No error is displayed. When I try to open the file with oocalc test.csv the same happens. I have tried different versions of OpenOffice.

What is wrong with the file? How can I get an error message out of OpenOffice?

Update: It does not have anything to do with the use of semicolons. I have reduced the file to 4 charaters. A file with the contents ID;A opens the CSV import dialog. But a ID;E opens an empty sheet. Why?

Update 2: The pattern id;E also works. ID;E must be some kind of magic code. Does anybody know the meaning?

回答1:

ID; in the first 3 characters of a file is the signature for a SYLK file. The fourth character can be a P, N or an E which flags certain information about how the rest of the file should be processed... so your "CSV" file is almost certainly being parsed as a SYLK file when that initial signature is read, and the remainder of the file is not valid SYLK format.



回答2:

CSV means C omma S eparated V alues, which is not what your document contains.

Those are semicolons.

If possible, change the PHP code to generate this instead (which is actually CSV):

ID,E-Mail_User,Name,Applikation,Rolle,Auftragsdatum,Administrator
522,user@domain,WXDUILAS,ABCD,XYZ,2009-03-04 05:00:09,user@domain

...or specify ; as the delimiter using the Text Import dialog.



回答3:

Add space after ID (i.e. "ID ").

Not the perfect solution but worked for me.