Menu

#853 Support for npz and npy files

closed-fixed
nobody
None
5
2026-03-24
2025-08-28
No

Bill asked me to read in data produced by Python's np.save command, where a variable is dumped to a binary file along with metadata to support multi-dimensional arrays. An npz file is a zip file containing multiple npy files.

Autoplot's .zip filesystem support handles the npz part, and I wrote a parser quickly with the help of ChatGPT.

These should be recognized by Autoplot and supported file extension types.

Discussion

  • Jeremy Faden

    Jeremy Faden - 2025-08-28

    This is done and will be in the next release.

     
  • Jeremy Faden

    Jeremy Faden - 2025-08-28

    Note structures are not supported--only int, double, and long types.

     
  • Jeremy Faden

    Jeremy Faden - 2025-08-28

    Here's code for writing a string to a file:

    import numpy as np
    
    arr = np.array(["hello", "world"], dtype='<U10')
    np.save("strings.npy", arr)
    
    loaded = np.load("strings.npy", allow_pickle=False)
    print(loaded)       # ['hello' 'world']
    print(loaded.dtype) # <U10
    
     
  • Jeremy Faden

    Jeremy Faden - 2025-10-22

    I noticed when playing with v2025a_11 that something is missing from the zip file implementation. So this is not done...

     
  • Jeremy Faden

    Jeremy Faden - 2025-10-24
    1. make a file mydata.npz file in /tmp/ap/
    2. make a file mydata.zip file in /tmp/ap/
    3. type /tmp/ap/mydata and hit tab to trigger completions.
    4. Note that the .zip completion is presented as a directory with a slash, while .npz is not.

    I'm not sure if that's really a problem or not, since we might want to have a source which handles npz files directly (and maybe allowing X=...&Y=...&Z=... as with IDLSAVE files).

     
  • Jeremy Faden

    Jeremy Faden - 2026-03-24
    • status: open --> closed-fixed
     
MongoDB Logo MongoDB