def _readTMY2(string, columns, hdr_columns, fname):
    head=1
    date=[]
    with open(fname) as infile:
        fline=0
        for line in infile:
            #Skip the header
            if head!=0:
                meta = _parsemeta_tmy2(hdr_columns,line)
                head-=1
                continue
            #Reset the cursor and array for each line    
            cursor=1
            part=[]
            for marker in string.split('%'):
                #Skip the first line of markers
                if marker=='':
                    continue
            
                #Read the next increment from the marker list    
                increment=int(re.findall('\d+',marker)[0])

                #Extract the value from the line in the file
                val=(line[cursor:cursor+increment])
                #increment the cursor by the length of the read value
                cursor=cursor+increment
         

                # Determine the datatype from the marker string
                if marker[-1]=='d':
                    try:
                        val=float(val)
                    except:
                        raise Exception('WARNING: In'+__name__+' Read value is not an integer" '+val+' " ')
                elif marker[-1]=='s':
                    try:
                        val=str(val)
                    except:
                        raise Exception('WARNING: In'+__name__+' Read value is not a string" '+val+' " ')
                else: 
                    raise Exception('WARNING: In'+__name__+'Improper column DataFrameure " %'+marker+' " ')
                
                part.append(val)
            
            if fline==0:
                axes=[part]
                year=part[0]+1900
                fline=1
            else:
                axes.append(part)
            
            #Create datetime objects from read data
            date.append(datetime.datetime(year=int(year),month=int(part[1]),day=int(part[2]),hour=int(part[3])-1))

    TMYData = pd.DataFrame(axes, index=date, columns=columns.split(',')).tz_localize(int(meta['TZ']*3600))

    return TMYData, meta
dataset/ETHPy150Open pvlib/pvlib-python/pvlib/tmy.py/_readTMY2/original