1

A small CSV file that was generated on a Windows server is not opening correctly on Linux/Mac.

The only way to open this file is via MS Excel for Mac, which gives the following prompt:

enter image description here

The CSV file has the proper extension .csv and "get info" in Finder shows that it is in-fact a CSV file. Weird thing is that it is called "Comma Separated Spreadsheet" rather than "Comma Separated Values":

enter image description here

When opening the file with TextEdit, the result is an empty file:

enter image description here

When using the file command in Terminal, the output is not "CSV" as it should be. It says it is "Zip archive data":

enter image description here

Is this a common error with CSVs between OS's? Unable to find any resources online. Appreciate the help.

4
  • 1
    You can use cat or xxd on the file in the terminal to see the raw file contents, rather than relying on TextEdit, which appears to be reading it as an RTF file. If it is an intact CSV file, you should see human-readable file contents. If the file is very large, use a command like cat file.csv | head -n5 to just see the first few lines.
    – Jivan Pal
    Commented Jan 24, 2020 at 20:10
  • @JivanPal running cat on file does not display human-readable file contents. Suspect there is an error with how it is being saved on Windows server side. Thanks. Any other thoughts?
    – Kubie
    Commented Jan 24, 2020 at 20:13
  • 1
    Are you sure that the file was actually saved in MS Excel as a CSV file, and someone did not simply change the file extension from .xlsx to .csv? If the file extension was changed, this explains why file reports that it is a ZIP file, since XLSX files are simply zipped directories containing XML files. Try changing the file extension to .xlsx and see what happens.
    – Jivan Pal
    Commented Jan 24, 2020 at 20:20
  • 1
    @JivanPal that was exactly it, thanks for the thought.
    – Kubie
    Commented Jan 24, 2020 at 20:22

1 Answer 1

3

Since file reports that the supposed .csv file is a Zip archive, it may actually be an XLSX (Microsot Excel) file whose file extension was simply changed from .xlsx to .csv. Try changing the file extension to .xlsx to see if this is the case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .