Select to view content in your preferred language

Provide list of known GIS extensions

310
0
02-26-2024 07:31 AM
Status: Open
AlfredBaldenweck
MVP Regular Contributor

This is a followup to Functio to List Non-GIS files - Esri Community, which was closed. Apparently, it's too much work to whitelist file types. But it should be pretty easy to blacklist them?

To take @EsriQruqs's idea:

Even better (IMO) and far easier would be for Esri to provide a list of known GIS extensions, much like:

>>> import string
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'

But instead one would receive a list of strings.

This they could tuck away in some simple module and make it available for downloading or something. Or why not just a code snippet somewhere in the docs?

So, in your code you could do:

for FILE in os.listdir('.'):
    if not os.path.splitext(FILE)[1] in gistypes:
        other_files.append(FILE)

I think this is a pretty viable solution, with the added bonus of the publisher making this information available instead of the user(s) independently trying to compile a list of file extensions based on their own data.