import numpy as np
import pandas as pd
import matplotlib as mpl
import os
import math
import glob
import datetime
from matplotlib import pyplot as plt
path=r'E:\Sonic Data\txt'
file=glob.glob(os.path.join(path, "TOA5_WEATHER_TEN_*.dat"))
db=[]
for f in file:
db.append(pd.read_csv(f,header=1,skiprows=[2,3],usecols=["TIMESTAMP","P_8_Avg","RH_8_Avg","Ta_8_Avg","WS_8_WVc(1)","WS_8_WVc(2)"]))
wea=pd.concat(db)
wea=pd.concat(db)
wea['TIMESTAMP']=pd.to_datetime(wea['TIMESTAMP'])
wea.set_index(wea['TIMESTAMP'],inplace=True)
wea.sort_index(level=0,inplace=True)
wea.drop(['TIMESTAMP'],axis=1,inplace=True)
wea.columns=['P','RH','T','WS','WD']
index2=pd.date_range(start = '2019/12/10 16:30:00',end='2020/1/1 00:00:00 ',freq = '600S') ## 检查时间是否存在缺测
wea.to_csv('GC_wea.csv')
网友评论