Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:01:28+00:00 2026-06-03T20:01:28+00:00

How can I automatically process ascending file names and array names in Numpy: I

  • 0

How can I automatically process ascending file names and array names in Numpy:

I have a series of HDF5 files named:

20120101.hdf5, 20120102.hdf5, 20120103.hdf5, ..., 20120130.hdf5, 20120131.hdf5  

each of the hdf5 file contains several arrays naming:

array1, array2, array3, ..., array24

I want to modify each of the arrays seperately and then create corresponding new hdf5 files. For example, using 20120101.hdf5:

import numpy
import tables

file = openFile("20120101.hdf5","r")
b1 = file.root.array1
c1 = (b1<=1)
new20120101_array1 = creatArray('/','1',c1)
c2 = ((b1<=2) and (b>1))
new20120101_array1 = creatArray('/','2',c2)
.
.
.

c20 = ((b1<=20) and (b>19))
new20120101_array1 = creatArray('/','20',c20)

and repeat it for arrays 2-24. As a result, I want to have:

new20120101.hdf5 ---- new20120101_array1 ---- 1
                                              2
                                              ...
                                              20
                 ---- new20120101_array2 ---- 1
                                              ...
                                              20
                 ...
                 ---- new20120101_array24 --- 1
                                              ...
                                              20
new20120102.hdf5
....
new20120131.hdf5
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:01:29+00:00Added an answer on June 3, 2026 at 8:01 pm

    If you have several files in a directory, you can use the os.listdir function, which returns a list containing the names of the entries in the directory.

    Example:

    import os
    import tables
    
    direc = '/Users/cg/' # the working directory (where your files are stored)
    dirs = os.listdir(direc)
    
    for idir in dirs: # this will iterate over the files in your working directory
    
        if idir.endswith('.he5'): # only for HDF5 files...
            hdf5 = tables.openFile(os.path.join(direc,idir))
    
            #### DO WHAT YOU WANT WITH EACH FILE!
    
            hdf5.close()
    

    The other part of your question is already answered in your other question, I guess (you can use the walkNodes function ).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java process that opens a file using a FileReader. How can
I was wondering if there was a tool that can pre-process CSS and automatically
How can I pick out files using todays date? I have files that have
How can automatically I stop the development web server when I stop debugging in
where can i find this class StringEscapeUtils that can automatically escape the characters instead
Is there some tool that can automatically convert the following c style code A
Is there an ISAPI filter that can automatically add the Last-Modified header in IIS?
Mongo docs state: The Mongo multikey feature can automatically index arrays of values. That's
Can I automatically validate complex child objects when validating a parent object and include
How can I automatically run some code when a WPF form is closed?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.