I'm not sure what you're asking for here, but more than 50 lines of code could be eliminated from your script with the following refactor:
def combineDatasets(DS1, DS2, DS3, DS4, DS5, DS6, DS7, DS8, DS9, DS10, DS11, DS12, DS13, DS14, DS15, DS16, DS17, DS18, DS19, DS20, DS21, DS22, DS23, DS24, DS25, DS26, DS27, DS28, DS29, DS30, DS31, DS32, DS33, DS34, DS35, DS36, DS37, DS38, DS39, DS40, DS41, DS42, DS43, DS44, DS45):
headers = ["t_stamp","Well","GPU","<HTML><center>Flow Rate<BR>-MMCFD-","<HTML><center>Total Gas TDY<BR>-MMCF-","<HTML><center>Total Gas YDY<BR>-MMCF-","<HTML><center>Tubing<BR>-PSI-","<HTML><center>Casing<BR>-PSI-","<HTML><center>9 5/8<BR>-PSI-","<HTML><center>13 3/8<BR>-PSI-","<HTML><center>Surface Casing<BR>-PSI-","<HTML><center>Sand Trap<BR>-PSI-","<HTML><center>Separator<BR>-PSI-","<HTML><center>WH Static<BR>-PSI-","<HTML><center>WH DP<BR>-PSI-","<HTML><center>Midstream<BR>-PSI-","<HTML><center>Delivery Static1<BR>-PSI-","<HTML><center>Delivery Static2<BR>-PSI-","<HTML><center>Filter Sep<BR>-PSI-","<HTML><center>Filter Sep DP<BR>-PSI-","<HTML><center>Dew Point<BR>-LB/H<sub>2</sub>O-","Choke","<HTML><center>Brine Flow<BR>-BBLD-","<HTML><center>Today Water<BR>-BBL-","<HTML><center>Yest. Water<BR>-BBL-","<HTML><center>Tank 1<BR>-BBL- ","<HTML><center>Tank 2<BR>-BBL- ","<HTML><center>Tank 3<BR>-BBL- ","<HTML><center>Tank 4<BR>-BBL- "]
data = []
for i in range(46)
dataset = DS + str(i)
row = []
for column in range(29)
row.append(eval(dataset).getValueAt(0,column))
data.append(row)
return system.dataset.toDataSet(headers,data)