Skip to content

Issue downloading zip dataset files from RRUFF site on Windows  #24

@RobertASu1

Description

@RobertASu1

I have a problem when trying to download a dataset from the rruff database. Using this slightly modified code from the Ramanspy doc site.

"""
Loading the RRUFF dataset

In this tutorial, we will see how to load the :ref:RRUFF data using RamanSPy.

"""
import sys
sys.path.append("c:\Pythoncode\Ramanspy\virt\Lib\site-packages")
import ramanspy
dataset_name = 'poor_oriented'
ramanspy.datasets.rruff("c:\Pythoncode\Ramanspy", download=True)

  I get this error message in Visual Studio code.  I'm using Windows 11.

File "c:\Pythoncode\Ramanspy\virt\ii_rruff.py", line 21, in
    ramanspy.datasets.rruff("c:\Pythoncode\Ramanspy", download=True)
  File "c:\Pythoncode\Ramanspy\virt\Lib\site-packages\ramanspy\datasets.py", line 464, in rruff
    return _download_rruff(dataset)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Pythoncode\Ramanspy\virt\Lib\site-packages\ramanspy\datasets.py", line 478, in download_rruff
    with ZipFile(BytesIO(zipresp.read())) as zipfile:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\RobertS\AppData\Local\Programs\Python\Python312\Lib\zipfile_init
.py", line 1339, in init
    self.RealGetContents()
  File "C:\Users\RobertS\AppData\Local\Programs\Python\Python312\Lib\zipfile_init
.py", line 1406, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file error when script is run

cody says the error error is occurring in the ramanspy library's dataset downloading functionality, so ensuring you have the latest version of the library might also help, but I just installed the program less than a week ago and I'm sure that's not the problem. I'm using 0.2.10. When I download and extract the zip file with Windows and run a ramanspy script to print out the metadata such as this:

dataset_name = 'fair_oriented' # Replace with the desired dataset name
spectra, metadata = rp.datasets.rruff(dataset_name, download=False) # Display some information about the loaded spectra
print(f"Loaded spectra for dataset: {dataset_name}")
print(f"Number of spectra: {len(spectra)}")
print(f"Metadata: {metadata}")

It prints out everything as it should, so I'm wondering if the problem is the zip files are in the wrong format at the RRUFF database?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions