Hacker News new | ask | show | jobs
by jakobegger 2332 days ago
I agree that you should use care when using file. My app relied on "file" to identify file types, and in some cases it mis-identified some Microsoft Office files. The problem was that Apple ships a very old magic file with macOS, and when I reported the bug they said they don't care.
4 comments

Excel mis-identifies CSV files whose first column is named "ID" as SYLK files.

But who would EVER think of naming the first column of a spreadsheet "ID"?

https://www.optibrium.com/community/forums/6-general-how-do-...

>Q: I have saved the result table from admensa into .csv format. However I am not able to open in excel. It is said that SYLK: file format is not valid. Do you have any experience on it? Thanks.

>A: This is an Excel 'feature.' I would guess that the first column of your data is entitled "ID". For some reason, Excel interprets any CSV file beginning with "ID" as an SYLK format file (not really sure what that is!). If you edit the file in, say, Notepad and change the name of the first column in the header row, you should find that it will load without a problem.

>This will happen if you save a CSV file from any application with the first characters "ID". So, unfortunately, there's not much we can do about it, other than to recommend that users don't call their first column "ID"!

Excel actually mostly ignores the extension and relies on heuristics to detect the file type on load. Many web applications used to implement "XLS export" by writing out CSV file with .xls extension.

This magic detection of file type has one unfortunate side effect: it is not exactly obvious how to convince Excel to load plain text data that is not CSV with delimiters from the current locale. (which is major PITA with most European locales where Excel uses "Semicolon"-SV and not "Comma"-SV but still calls it CSV)

You’ll have to excuse me because I’m not in front of a windows computer right now, but if you open excel first, there is a data tab on the ribbon and an import data wizard or something like that and you can tell it what the delimiter is. You can also apply types to columns and whatnot before importing. Not the quickest but does help extract the data.
This is a fairly new feature in Excel.

The lack of this feature pushed a lot of scientists to OpenOffice/LibreOffice Calc. At first, just to open the file and "Save as Excel", but of course, then they start using Calc.

(At least that's my experience writing scientific software in Europe. Excel localized not just display, but the input and output. With Calc you could just open a file as "pipe separated UTF-8" and be done with it.)

If you rename your .csv as .txt then you get a wizard where you can choose delimiters, etc. This works in Excel 2000. I don't have an older version to hand.
I'm aware of that. But that is also partly my point, before ribbon there was 'File->Import...' which did essentially the same thing but at least for me (and many users I work with) was more discoverable.

Another thing is that LO Calc will present you with text import dialog when you open anything vaguely text like and also when you paste multiline plain text from clipboard.

> Apple ships a very old magic file with macOS

I particularly relish the way it identifies macOS disk image files as VAX executables. I hope they never change that.

Oh yeah, I got bitten by that. Turns out that MS Office files are zip-compressed xml files. Well I didn't know that, and the files were named something like data.csv, so that left me confused until a coworker told me what's up.
Not sure why people think they can rely on the pre-installed Unix utilities on macOS.

EDIT: Apple routinely don't update the Unix utilities for a decade...

Yeah, those idiots! They buy something from Apple, and then find it doesn't work. What did they expect.

This, of course, is passive-aggressive snark. Suffice to say that I disagree with you; why shouldn't people expect software they buy from Apple to work? People buy from Apple because they don't want to have to deal with all this sort of crap; they just want it to work.

I am more surprised Apple doesnt invest in their own Unix utils packages honestly. Its not like they dont have the money to do so.
Steve Jobs originally wanted to strip out the shell entirely and only support POSIX at the level of the C API. To this day, Apple acts like they've been strong-armed into providing support for the Unix utilities.

I can understand the attitude that 99% of their userbase will never touch the command line, but that last 1% represents the developers that keep the whole ecosystem going.

We actually broadly agree that it is a shame that Apple don't support their Unix utilities.