5 ms·
No. From the detailed description: > A SYLK file is a text file that begins with "ID" or "ID_xxxx", where xxxx is a text string. The first record of a SYLK fil
by boulos 10y ago
No. From the detailed description:
> A SYLK file is a text file that begins with "ID" or "ID_xxxx", where xxxx is a text string. The first record of a SYLK file is the ID_Number record. When Excel identifies this text at the beginning of a text file, it interprets the file as a SYLK file. Excel tries to convert the file from the SYLK format, but cannot do so because there are no valid SYLK codes after the "ID" characters. Because Excel cannot convert the file, you receive the error message.
This is usually called "magic string" or "magic number" (https://en.m.wikipedia.org/wiki/Magic_number_(programming) https://en.m.wikipedia.org/wiki/Magic_number_(programming)). It has nothing to do with the comma, and everything to do with SYLK using a pretty risky magic string (ID) and Excel not having a "try SYLK, if that fails, try as csv".
tl;dr: this is about guessing the input format and has nothing to do with the delimiter.
- mhd 10y agoIt's not just ID, there's also mandatory fields after that, separated by a semicolon. Thus 'ID;P' would be a valid header for SYLK and e.g. for German "CSV"s. If CSV would stick to commas (and boohoo, just escape more fields when this causes locale issues), then even such overly simple heuristics would've sufficed, wouldn't it? Although you'd just run into other pathetic cases with such an informal format (CSV, not SYLK). But hey, I need to interchange formats with some IT guys and don't have a big IT department (ready) and they don't want to parse XLS(X), so I just use CSV. Now you have two problems.
- philh 10y ago"ID;P" is valid at the start of CSV as well. Fields are allowed to contain semicolons.
- Frank2312 10y agoDepending on locale. I believe in the Canadian French locale (and maybe many other locales), ";" is considered a separator (a "," equivalent).
- philh 10y agoSure, but mhd was saying that if we stuck to CSV being actually comma-separated, "ID;P" would distinguish CSV from SYLK. I'm saying that it wouldn't.
- Someone 10y agomhd doesn't say that: Thus 'ID;P' would be a valid header for SYLK and e.g. for German "CSV"s.
- philh 10y ago"If CSV would stick to commas ... then even such overly simple heuristics would've sufficed, wouldn't it?"
- Someone 10y agoAh, thanks. Apparently, mhd knew and forgot :-) The problem of discriminating between csv and SYLK files is unsolvable, as every file with only ASCII characters and no commas or quotes is a valid csv file (with one column) and there are valid SYLK files in that set.
- ufmace 10y agoIn the general sense, yeah, but you would think it shouldn't be too hard to make a reasonable guess about which one it is and handle failures gracefully instead of assuming that it's SYLK based on a tiny amount of data and then blowing up when it turns out not to be.
- mark-r 10y agoValid, but not nearly as likely to run into by accident.