Each row in data is a different exipiration time, and each column corresponds to various strikes as given in strikes . We load all this data into the QuantLib Matrix object. This can then be used seamlessly in the various surface construction routines. The variable implied_vols holds the above data in a Matrix format. One unusual bit of info that one needs to pay attention to is the ordering of the rows and columns in the Matrix object. The implied volatilities in the QuantLib context needs to have strikes along the row dimension and expiries in the column dimension. This is transpose of the way the data was constructed above. All of this detail is taken care by swapping the i and j variables below. Pay attention to the line:

implied_vols[i][j] = data[j][i]

in the cell below.