티스토리 뷰

 

 

def Test12(weatherStation1):
    #weatherStation1 = WeatherStationList[0]
    print(weatherStation1)
    startTime = theBeginning
    endTime = startTime + timedelta(days=30)
    startTimeString = startTime.strftime('%Y-%m-%d')
    endTimeString = endTime.strftime('%Y-%m-%d')
    isFileCreated = False
    dataLength = 0
    while(True):
        weatherData1 = LoadWeatherDatas(weatherStation1['StationCode'], startTimeString, endTimeString)
        if weatherData1:
            if not isFileCreated:
                filename = "E:/tttt/"+weatherStation1['StationCode']+"_AllData01.csv"
                file1 = open(filename, "w")
                weatherData1 = LoadWeatherDatas(weatherStation1['StationCode'], startTimeString, endTimeString)
                print(weatherData1[0].keys())
                #print(weatherData1)
                aWeatherData = weatherData1[0]
                keys1 = aWeatherData.keys()
                for key1 in keys1:
                    if(key1=="iscs"): continue
                    file1.write(key1+',')
                file1.write('\n')
                isFileCreated = True
            for aWeatherData in weatherData1:
                for key1 in keys1:
                    if(key1=="iscs"): continue
                    file1.write(aWeatherData[key1]+',')
                file1.write('\n')
            dataLength += len(weatherData1)
            print(weatherData1[0]['tm'], "(",len(weatherData1),")")
        if(endTime >= theNow): break
        startTime = endTime + timedelta(days=1)
        endTime = startTime + timedelta(days=60)
        startTimeString = startTime.strftime('%Y-%m-%d')
        endTimeString = endTime.strftime('%Y-%m-%d')
        print(startTimeString, " to ", endTimeString)
    
    if isFileCreated: file1.close()

def Test13():
    weatherStation1 = WeatherStationList[0]
    startIndex = 1
    index1 = 0
    for weatherStation1 in WeatherStationList:
        if(index1 < startIndex): 
            index1+=1
            continue
        Test12(weatherStation1)
        index1+=1
    
Test13()    

반응형