本文整理汇总了Python中Table.Table.add_value方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add_value方法的具体用法?Python Table.add_value怎么用?Python Table.add_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table.Table
的用法示例。
在下文中一共展示了Table.add_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from Table import Table [as 别名]
# 或者: from Table.Table import add_value [as 别名]
def load(self):
timestamp = 0
db = Database()
for file_name in DATA_FILE_NAMES:
# generate the name of the table from the filename
table_name = re.match('[^\.]+', file_name).group()
new_table = Table(table_name)
full_path = os.path.join(self.data_dir, file_name)
with open(full_path, 'r') as data_file:
first_line = True
for line in data_file:
elems = line.split()
if (first_line):
# generate col names from the filename plus col num
# starting with timestamp
new_table.add_column_name(TIMESTAMP_COL_NAME)
num_columns = len(elems) + 1
for col_num in range(1, num_columns):
new_table.add_column_name(table_name + str(col_num))
first_line = False
# add vals for each new row, starting with timestamp
new_table.add_value(timestamp, TIMESTAMP_COL_NAME, timestamp)
for elem_num in range(len(elems)):
col_name = table_name + str(elem_num+1)
new_table.add_value(timestamp, col_name, elems[elem_num])
timestamp += 1
# finally, add the table we just built to the db
db.add_table(new_table)
return db