I just had this issue, I have some weather files with .pvsyst
extensions (you can see the head of the file below) and I found it easier to just use the pandas.
First, change the extension of the file to .csv
, then open the file and check if it has any comments or info lines. In my case, the files start with many comment lines and also one line with info regarding unit:
#TMY hourly data
#Standard format for importing hourly data in PVsyst
#Created from EnergyPlus Weather Converter version=2022.04.01
#WMO=105130Data Source=Custom-105130
#Site,Koln.Bonn.AP
#Country,DEU
#Data Source,Custom-105130 WMO=105130
#Time step,Hour
#Latitude,50.864
#Longitude,7.158
#Altitude,100
#Time Zone,1.00
Year,Month,Day,Hour,Minute,GHI,DHI,DNI,Tamb,WindVel,WindDir
,,,,,W/m2,W/m2,W/m2,deg.C,m/sec,�
2059,1,1,1,30,0,0,0,0.000,1.00,21
2059,1,1,2,30,0,0,0,0.000,1.00,120
This means I need to tell the pandas that the lines that start with #
are comments and later drop the first index:
df = pd.read_csv('weather.csv', comment='#')
print(df.head())
df = df.drop(0)
print(df.head())
Output:
Year Month Day Hour Minute GHI DHI DNI Tamb WindVel WindDir
0 NaN NaN NaN NaN NaN W/m2 W/m2 W/m2 deg.C m/sec �
1 2059.0 1.0 1.0 1.0 30.0 0 0 0 8.000 3.00 250
2 2059.0 1.0 1.0 2.0 30.0 0 0 0 8.000 4.00 260
3 2059.0 1.0 1.0 3.0 30.0 0 0 0 8.000 4.00 240
4 2059.0 1.0 1.0 4.0 30.0 0 0 0 8.000 4.00 240
Year Month Day Hour Minute GHI DHI DNI Tamb WindVel WindDir
1 2059.0 1.0 1.0 1.0 30.0 0 0 0 8.000 3.00 250
2 2059.0 1.0 1.0 2.0 30.0 0 0 0 8.000 4.00 260
3 2059.0 1.0 1.0 3.0 30.0 0 0 0 8.000 4.00 240
4 2059.0 1.0 1.0 4.0 30.0 0 0 0 8.000 4.00 240
5 2059.0 1.0 1.0 5.0 30.0 0 0 0 8.000 4.00 240