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'
4

0 回答 0