OpenOffice Calc can not read a simple CSV file. Why?

老子叫甜甜 提交于 2019-12-20 04:53:11

问题


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.



来源:https://stackoverflow.com/questions/6032049/openoffice-calc-can-not-read-a-simple-csv-file-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!