0

moving window to grab hourly reading, netcdf file, python what am i doing wrong here i want to grab 4 files then move to the
next 4 files? what i want to do i grab the first 4 then move to the next 4 as below.. im trying to match it with the file naming structure. # in the front of the filename

as in  
1  
2  
3  
4

2  
3  
4  
5 

filenaming structure 1_NLDAS_NOAH0125_H.A19871017.2100.002.2016198135018.pss.nc
2_
3_
to xxxx_

import os
import shutil
import re, glob

part1 = (r"C:\test\year198666")

def Iteration_4():

    rearrange1_file_list = os.listdir(part1)
    saved_path = os.getcwd()
    print("Current Working Directory os "+saved_path)
    os.chdir(part1)
    i = 1 #starting at day 1 plus 3 files


    a = i
    print 'grabing file',(a)
    b = i+1
    print 'grabing file',(b)
    c = i+2
    print 'grabing file',(c)
    d = i+3
    print 'grabing file',(d)
    while i < 10:
        for oldnames3 in rearrange1_file_list:
            rearrange1_file_list.sort()
            num3 = oldnames3.split("_")                              
            xyz = (num3[0])
            #print (xyz)
            if xyz == (a):
                print(a)
            elif xyz == (b):
                print(b)
            elif xyz == (c):
                print(c)
            elif xyz == (d):
                print(d)
         #   for letter in i:          
Iteration_4()
print 'done'
A.A
  • 13
  • 6
  • Can you please clarify what you are trying to do and what your question is? As far as I can tell, this has nothing to do with the `netcdf` tag. – jhamman Aug 03 '16 at 22:54
  • correct, im working with netcdf files, and sometimes they tend to include multidimemsion time series thats the only reason why i tag it as netcdf file but back to my question – A.A Aug 04 '16 at 01:43
  • correct, im working with NetCDF files, and sometimes they tend to include multidimensional time series thats the only reason why i tag it as netcdf file but back to my question i want to group these files by 4 then move to the next four ----- example grab file name from 1_xxx_xxx.nc to file 4_xxx_xxx.nc then move to the next window filename 2_xxx_xxx.nc to 5_xxx_xxx.nc then to next window 3_xxx_xxx.nc to 6_xxx_xxx.nc so on so fort to the end of my files roughly 20000 files--- in the end i want to create folders for each four files that i grab... please let me know if i clarified my question- – A.A Aug 04 '16 at 02:08

0 Answers0