本文整理汇总了Python中table.Table.append_column方法的典型用法代码示例。如果您正苦于以下问题:Python Table.append_column方法的具体用法?Python Table.append_column怎么用?Python Table.append_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.append_column方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: result
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import append_column [as 别名]
def result(self):
""" Perform the query, and return the result as a Table object """
BaseQuery.logger.log( "With arguments: " + str(self.arguments) )
BaseQuery.logger.log( "Running query: \n" + str(self.complete_query) )
cursor = self.db_connection.cursor()
start_time = time.time()
cursor.execute( self.complete_query )
self.elapsed_time = time.time() - start_time
BaseQuery.logger.log( str(self.elapsed_time) + " seconds" )
results_table = Table()
for col in cursor.description:
results_table.append_column( col[0] )
row = cursor.fetchone()
while row:
results_table.append_row( [self.output_clean_function(i) for i in row] )
row = cursor.fetchone()
self.rows_fetched = len(results_table)
BaseQuery.logger.log( str(self.rows_fetched) + " rows fetched" )
return results_table
示例2: sin_clean
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import append_column [as 别名]
for row in table.row_maps():
clean_attempt = ""
if group_name == 'sin':
clean_attempt = sin_clean( row[column] )
if group_name == 'dates':
clean_attempt = date_clean( row[column] )
if group_name == 'semesters':
clean_attempt = semester_clean( row[column] )
translation_table[ row[ column ] ] = clean_attempt
if os.path.exists( group_name + ".csv" ):
t = Table.from_csv( group_name + ".csv" )
for row in t.rows:
if row[0] in translation_table and translation_table[ row[0] ] != "" and row[1] == "":
pass
else:
translation_table[ row[0] ] = row[1]
column_index = table.headers.index(column)
for row in output_table.rows:
if row[column_index] in translation_table and translation_table[row[column_index]] != "":
row[column_index] = translation_table[row[column_index]]
t = Table()
t.append_column( group_name )
t.append_column( "canonical" )
for key, value in translation_table.iteritems():
t.append_row( [ key, value ] )
t.to_csv( group_name + ".csv")
output_table.to_csv( "output.csv" )