Question: I have just tried to import a shapefile and got the message 'magic number mismatch'. How do I solve the issue and import the file?
Wow. We don't see that very often, as it's usually a sign of a corrupted shape file or a compressed file that hasn't been named correctly. Occasionally, when downloading from a web site, files will arrive with no extension. If you rename a file like this to be a .shp file and it results in the 'magic number mismatch' error, it is most likely that the downloaded file was some kind of archive file, most likely a ZIP file, but missing the .zip extension.
A common way to resolve this is to change the file name and extract the original shapefile data:
- In the Finder select the file and change the name end in ".zip"
- You will be prompted with whether to add the extension or not, which you should answer to Add the extension
- Once that's done, double-click on the file and it should extract the files into a new directory
A little more detail
In short, the 'magic number mismatch' error means that the file is missing a key binary sequence at the beginning of the file that is supposed to verify that the shapefile is indeed a shapefile and not just another file that happens to be named ending in .shp.