本文整理汇总了Python中Table.Table类的典型用法代码示例。如果您正苦于以下问题:Python Table类的具体用法?Python Table怎么用?Python Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, argv):
FILE = open("RunInfoAll.txt","w")
for siteIdx in range(1,4):
# 1,2,3 -> 1,2,4
site = siteIdx
if siteIdx==3:
site = 4
print siteIdx,argv[siteIdx]
table = Table()
table.read( argv[siteIdx] )
if siteIdx==1:
FILE.writelines( table.headerLine )
for row in range(0, table.nRows):
# print table.columns["Site"][row]
if int( table.columns["Site"][row] ) == site:
for col in range(0, len(table.fieldNames)):
FILE.writelines( table.columns[ table.fieldNames[col] ][row] )
FILE.writelines("\t")
FILE.writelines("\n")
FILE.close()
示例2: read_files
def read_files():
path = os.curdir+"/csv_files/"
print(os.curdir)
files = os.listdir(path)
tables = []
for file in files:
if file.endswith(".csv"):
t = Table("", "", "")
# set table name from file name
t.tableName = file.title()[:-4].lower()
f = open(path + file)
csv_f = csv.reader(f)
csv_list = list(csv_f)
# set headers and rest of data
t.headers = csv_list[0]
t.rows = csv_list[1:]
tables.append(t)
print_file_names(tables)
return tables
示例3: write
def write(self, writePgLinks=True):
# returns a list with each element as (link to table
# row, row)
ret_data = []
self.mkdir_p(self.outputdir)
nRows = self.table.countRows()
pgCounter = 1
for i in range(0, nRows, self.rowsPerPage):
rowsSubset = self.table.rows[i : i + self.rowsPerPage]
t = Table(self.table.headerRows + rowsSubset)
ret_data.append((pgCounter, rowsSubset))
f = open(os.path.join(self.outputdir, str(pgCounter) + '.html'), 'w')
f.write('<head>')
f.write('<script src="http://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>\n')
f.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>\n')
f.write('</head>')
pgLinks = self.getPageLinks(int(math.ceil(nRows * 1.0 / self.rowsPerPage)),
pgCounter, self.pgListBreak)
if writePgLinks:
f.write(pgLinks)
f.write('<p>' + self.desc + '</p>')
f.write(t.getHTML(makeChart = self.makeChart, transposeTableForChart=self.transposeTableForChart, chartType = self.chartType, chartHeight = self.chartHeight))
if writePgLinks:
f.write(pgLinks)
f.write(self.getCredits())
f.close()
pgCounter += 1
return ret_data
示例4: __init__
def __init__ (self, callback, container, *args, **kwargs):
Table.__init__ (self, *args, **kwargs)
self.id = "sortablelist_%d" %(self.uniq_id)
self.url = "/sortablelist_%d"%(self.uniq_id)
self.container = container
# Register the public URL
publish (self.url, changed_handler_func, method='POST',
callback=callback, key_id='%s_order'%(self.id), **kwargs)
示例5: __init__
def __init__ ( self, handle ):
self.name = 'nrdb'
self.fields = (
('nid', 'INT UNSIGNED NOT NULL'),
)
self.indices = (
'UNIQUE (nid)',
)
Table.__init__( self, handle )
示例6: __init__
def __init__ (self, callback, container, *args, **kwargs):
Table.__init__ (self, *args, **kwargs)
self.id = "sortablelist_%d" %(self.uniq_id)
self.url = "/sortablelist_%d"%(self.uniq_id)
self.container = container
# Secure submit
srv = get_server()
if srv.use_sec_submit:
self.url += '?key=%s' %(srv.sec_submit)
# Register the public URL
publish (r"^/sortablelist_%d"%(self.uniq_id), changed_handler_func,
method='POST', callback=callback, key_id='%s_order'%(self.id), **kwargs)
示例7: __init__
def __init__ ( self, handle, root = "domains"):
self.fields = (
('nid', 'INT UNSIGNED NOT NULL'),
('start', 'SMALLINT UNSIGNED NOT NULL DEFAULT 0'),
('end', 'SMALLINT UNSIGNED NOT NULL DEFAULT 0'),
('rep_ali', 'BLOB NOT NULL'),
('domain_id', self.mTypeDomainId),
('domain_from', 'SMALLINT UNSIGNED NOT NULL DEFAULT 0'),
('domain_to', 'SMALLINT UNSIGNED NOT NULL DEFAULT 0'),
('domain_ali', 'BLOB NOT NULL'),
('family', self.mTypeDomainClass ),
) + self.mExtraFields
self.indices = (
'INDEX (nid)',
'INDEX (domain_id)',
'INDEX (family)'
) + self.mExtraIndices
self.mFieldsNr = (
('nid INT UNSIGNED NOT NULL'),
('start SMALLINT UNSIGNED NOT NULL DEFAULT 0'),
('end SMALLINT UNSIGNED NOT NULL DEFAULT 0'),
('family %s' % self.mTypeDomainClass),
)
self.mIndicesNr = ( 'INDEX (nid)',
'INDEX (family)',
)
self.mRootName = root
Table.__init__( self, handle )
# minimum length of an assignment
self.mMinAssignmentLength = 10
# whether or not to shorten domains
self.mShortenDomains = 0
# minimum overlap between domains of the same did in order
# for them to be joined for making non-redundant set
# (had problems with scop and hemoglobins, there was one residue overlap)
self.mMinRedundancyOverlap = 0
## field to use as class identifier, this is the default
self.mClassNr = "family"
## additional info in each row, used for propagation
self.mAdditionalInfo = []
示例8: __init__
def __init__(self, handle, root):
self.mRootName = root
Table.__init__(self, handle)
self.fields = (
("family", self.mTypeDomainClass),
("nunits", "INT UNSIGNED NOT NULL DEFAULT 0"),
("nsequences", "INT UNSIGNED NOT NULL DEFAULT 0"),
("nresidues", "INT UNSIGNED NOT NULL DEFAULT 0"),
("length", "SMALLINT UNSIGNED NOT NULL DEFAULT 0"),
) + self.mExtraFields
self.indices = ("UNIQUE (family)",) + self.mExtraIndices
示例9: __init__
def __init__(self, connectionPool, name):
self.tabName = name
self.connectionPool = connectionPool
self.serverVersion = connectionPool.ServerVersion()
for part in self.connectionPool.dsn.split():
if part.startswith("dbname="):
self.dbName = part[7:]
cursor = connectionPool.GetCursor()
row = cursor.ExecuteRow(
"""
SELECT c.oid, relhasoids
FROM pg_class c
WHERE oid=oid(regclass('%s'))
"""
% self.tabName
)
if not row:
raise Exception(xlt("No such table: %s") % self.tabName)
self.oid = row["oid"]
self.hasoids = row["relhasoids"]
self.constraints = cursor.ExecuteDictList(Table.getConstraintQuery(self.oid))
self.colSpecs = {}
self.colNames = []
set = cursor.ExecuteSet(
"""
SELECT attname, attnotnull, atttypid, atttypmod, t.typcategory, CASE WHEN typbasetype >0 THEN format_type(typbasetype,typtypmod) ELSE format_type(atttypid, atttypmod) END as formatted
FROM pg_attribute a
JOIN pg_type t ON t.oid=atttypid
WHERE attrelid=%d
AND (attnum>0 OR attnum = -2) AND NOT attisdropped
ORDER BY attnum
"""
% self.oid
)
for row in set:
attname = row["attname"]
self.colNames.append(attname)
self.colSpecs[attname] = ColSpec(row)
self.primaryConstraint = None
if self.hasoids:
self.keyCols = ["oid"]
else:
for c in self.constraints:
if c.get("indisprimary"):
self.primaryConstraint = c
break
if not self.primaryConstraint:
for c in self.constraints:
if c.get("isunique"):
self.primaryConstraint = c
break
if self.primaryConstraint:
self.keyCols = self.primaryConstraint.get("colnames")
else:
self.keyCols = []
示例10: __init__
def __init__(self, lines):
# Turn padding into preceding number
lines = [ str(calculate_padding(line)) + ' ' + line.strip() for line in lines ]
self.table = Table()
self.lines = Lines(lines)
self.terminate = False
self.result = ""
return
示例11: init
def init(self):
self.recordList = []
self.tables = {}
self.table = Table(self.path, self.pageSize)
self.table.setTableFDP(4)
self.table.setTableNumber(2)
self.setMsysObjectColumns()
self.makeTables()
示例12: parseTable
def parseTable(handle):
inTable = handle.Offset
# Get table title
title = inTable(1,2).Value
if title is None:
title = ""
# Build table object
outTable = Table(title)
# Get axis titles
outTable.yTitle = inTable(2, 1).Value
outTable.xTitle = inTable(2, 3).Value
# Get axis units
outTable.yUnits = inTable(3, 1).Value
if outTable.yUnits is None:
outTable.yUnits = ""
outTable.xUnits = inTable(3, 3).Value
if outTable.xUnits is None:
outTable.xUnits = ""
# Iterate over the table
i = 4
while (not inTable(i, 1).Value is None):
outTable.yValues.append(str(inTable(i, 1).Value))
outTable.yErrors.append(str(inTable(i, 2).Value))
outTable.xValues.append(str(inTable(i, 3).Value))
outTable.xErrors.append(str(inTable(i, 4).Value))
i += 1
print inTable(i, 2).Value
return outTable
示例13: main
def main ():
prog = sys.argv[1]
## open program to parse (read whole program into memory, it's small enough)
with open(prog,'r') as f:
towerProgram = Program.removeCommentedText(f.read())
### parse instrumentlibrary for additional metadata
insLib = parse('instrumentlibrary.xml')
## parse program to get aliases, constants, and units
aliases = Program.getAliases(towerProgram)
constants = Program.getConstants(towerProgram)
units = Program.getUnits(towerProgram)
## start and initialize new xml for this program
doc = xmlutils.createNewProgramXML()
xmlutils.addTextNodeToRoot(doc,"progName",prog)
tablesNode = xmlutils.addNode(doc,'root','tables')
### put datatable info in the progxml
tables = Program.getTables(towerProgram)
for text in tables:
### use text and program info to construct Table object
table = Table(text,aliases,constants,units)
### add table info (name and interval) to xml
tableNode = doc.createElement("table")
table.addTableInfo(doc,tableNode)
### process output instructions and store variable info
### to the progxml
variablesNode = xmlutils.addNode(doc,tableNode,'variables')
table.processOutputInstructions(doc,variablesNode,insLib)
tablesNode.appendChild(tableNode)
#do some cleaning up of xml (so it's easy for humans to view in texteditor)
progxml = xmlutils.cleanupXML(doc)
### save progxml
xmlout = open(prog + '.xml','w')
print >>xmlout, progxml
示例14: toTable
def toTable(self, colName, fmt=None, type_=None, title="", meta=None):
"""
Generates a one column :py:class:`~libms.DataStructures.Table`
from an expression.
Example: ``tab = substances.name.toTable()``
"""
from Table import Table
return Table.toTable(colName, self.values, fmt, type_, title, meta)
示例15: __init__
def __init__ ( self, handle ):
self.name = 'nrdb'
self.fields = (
('updated', 'TIMESTAMP'),
('nid', 'INTEGER UNSIGNED NOT NULL AUTO_INCREMENT'),
('hid', 'CHAR(22) NOT NULL'),
('sequence', 'TEXT NOT NULL'),
('sequencedbs_id', 'TINYINT UNSIGNED NOT NULL'),
('accessionnumber', 'VARCHAR(20) BINARY NOT NULL'),
('identifier', "VARCHAR(20) BINARY NOT NULL DEFAULT ''"),
('description', "VARCHAR(255) NOT NULL DEFAULT ''"),
('created', 'DATE NOT NULL'),
('length', 'MEDIUMINT UNSIGNED NOT NULL DEFAULT 0'),
('filter', 'TINYINT UNSIGNED NOT NULL DEFAULT 100'),
)
self.indices = (
'PRIMARY KEY (nid)',
'INDEX hid (hid(4))',
'INDEX updated (updated)',
'INDEX filter (filter)',
)
Table.__init__( self, handle )