JuliaIO / FileIO.jl

Main Package for IO, loading all different kind of files
http://juliaio.github.io/FileIO.jl/
Other
217 stars 78 forks source link

Support for file extensions using uppercase letters #251

Open cbdavis opened 4 years ago

cbdavis commented 4 years ago

I'm running into problems when trying to read Excel files with uppercase extensions:

filename = "test.XLS"
df = DataFrame(load(filename, "Sheet1"))

Leads to

ERROR: NoDecodeDelegateForThisImageFormat `XLS' @ error/constitute.c/ReadImage/560

When I rename the file to test.xls everything works fine.

I'm also able to get things to work by changing the code here: https://github.com/JuliaIO/FileIO.jl/blob/9e6d49d57aaad3945a91b57f18ea5f45b73ef7e0/src/registry.jl#L35

to:

add_format(format"Excel", (), [".xls", ".xlsx", ".XLS", ".XLSX"], [:ExcelFiles])

I see that a few formats have definitions for upper and lowercase variants of the file extensions, although it seems like it would be more ideal to just convert the extension string to lower case when trying to figure out which format the file is in.

This might be related to #236

SimonDanisch commented 4 years ago

I find it bad style to support uppercase and lowercase extensions, which probably only a few extension vendors started doing. So I'm in favor of keeping this explicit for the few formats, that started allowing the uppercase version...

oxinabox commented 3 years ago

I don't think I agree. or at least not entirely. File format when recogizing by extension (rather than magic byte) should be done in a case-insensitive way. E.g. convert all of them to lower case before comparing.

Remembing that Windows historically uses a a case-insesitive file-system; and also historically depended a lot more on the extension to decide what to do with a file. In contrast to Unixen which has things like the shebang line to specfy interpretter.

I think it would be very weird to have a file extension that has to be in upper-case as the one way it is distinguished from another, simply because that wouldn't work in Windows.

JohannesNE commented 2 years ago

I ran into this issue with RData.jl. It not obvious to me (a Julia beginner) that capitalization of the file extension was the problem. I filed an issue at RData.jl (https://github.com/JuliaData/RData.jl/issues/91).

nalimilan commented 2 years ago

This has been reported again in RData. This might be a relatively exceptional case, but both "RData" and "Rdata" are widely used. FileIO already accepts both "RData" and "rdata", I guess we could add "Rdata" to the list but having something more systematic would be nice.

nalimilan commented 2 years ago

BTW, we already support both "jpg" and "JPG", .stl" and ".STL", ".fit" and ".FIT", ".fits" and ".FITS", ".fts" and ".FTS", ".mid" and ".MID", so it seems to me that case sensitivity really doesn't make sense in practice.