def create_interval_record_table(self): _table = DataTable() _table.Clear() _table.Columns.Add("id") _table.Columns.Add("username") _table.Columns.Add("firstname") _table.Columns.Add("lastname") return _table
def create_interval_record_table(self): _table = DataTable() _table.Clear() _table.Columns.Add("ID") _table.Columns.Add("Username") _table.Columns.Add("Lastname") _table.Columns.Add("Firstname") _table.Columns.Add("Userlevel") return _table
def __init__(self): self.Text = "Example App" self.Name = "ExampleApp" self.ClientSize = Size(370, 400) self.MinimumSize = Size(370, 300) self._table = DataTable() self._columns = { d[0]: self._table.Columns.Add(d[0], d[1]) for d in self._COLUMNS } self._loadPanel = Panel() self._loadPanel.Location = Point(0, 0) self._loadPanel.Size = Size(215, 30) self._loadPanel.Dock = DockStyle.Top self._fileTextBoxLabel = Label() self._fileTextBoxLabel.Text = "Load file" self._fileTextBoxLabel.Size = Size(100, 16) self._fileTextBoxLabel.Location = Point(5, 7) self._loadPanel.Controls.Add(self._fileTextBoxLabel) self._fileTextBox = TextBox() self._fileTextBox.Size = Size(200, 20) self._fileTextBox.Location = Point(110, 5) self._loadPanel.Controls.Add(self._fileTextBox) self._loadButton = Button() self._loadButton.Size = Size(50, 20) self._loadButton.Location = Point(315, 5) self._loadButton.Text = "Load" self._loadPanel.Controls.Add(self._loadButton) self._dataPanel = Panel() self._dataPanel.Location = Point(0, 35) self._dataPanel.Size = Size(370, 185) self._dataGrid = DataGridView() self._dataGrid.AllowUserToOrderColumns = True self._dataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize self._dataGrid.Location = Point(0, 0) self._dataGrid.Size = Size(360, 180) self._dataGrid.DataSource = self._table self._dataPanel.Controls.Add(self._dataGrid) self.Controls.Add(self._loadPanel) self.Controls.Add(self._dataPanel) self._loadButton.Click += self.loadData
def _get_DAX(connection_string, dax_string) -> "DataTable": dataadapter = ADOMD.AdomdDataAdapter(dax_string, connection_string) table = DataTable() logger.info("Getting DAX query...") dataadapter.Fill(table) logger.info("DAX query successfully retrieved") return table
def Data(self): data = DataTable() data.Columns.Add('ID', clr.GetClrType(str)) data.Columns.Add('Name', clr.GetClrType(str)) data.Columns.Add('Props', clr.GetClrType(str)) for content in self.Contents: data.Rows.Add(hex(content.ID), content.name, content.props) return data
def __init__(self, h): self.ctrl = ListView() self.table = DataTable('table') self.Initialize(h) if h.get('fontsize'): self.SetFontSize(h['fontsize']) if h.get('handler'): self.ctrl.SelectionChanged += h['handler'] self.grid = GridView() self.grid.AllowsColumnReorder = True self.grid.ColumnHeaderToolTip = "ListView Column Info" if h.get('columns'): items = h['columns'] width = None if h.get('widths'): width = h['widths'] for i in range(0, len(items)): col = GridViewColumn() col.DisplayMemberBinding = Binding(items[i]) col.Header = items[i] if width: col.Width = width[i] self.grid.Columns.Add(col) self.AddColumn(items[i]) self.ctrl.View = self.grid self.ctrl.ItemsSource = self.table.DefaultView #DataView(self.table)
def Data(self): data = DataTable() data.Columns.Add('ID', clr.GetClrType(str)) data.Columns.Add('X', clr.GetClrType(int)) data.Columns.Add('Y', clr.GetClrType(int)) data.Columns.Add('Sector', clr.GetClrType(str)) for tmap in self.treasureMaps: sector = self.GetSector(tmap.x, tmap.y) data.Rows.Add(hex(tmap.serial), tmap.x, tmap.y, sector) Misc.SendMessage( '{0}: SOS Data has been loaded.'.format(self.scriptName), 67) return data
def ExtractionDonnees(mdx_query, conn_string): """ Cette fonction permet d'extraire les données d'un cube. Les arguments sont : - la chaîne de connexion au cube - la requête MDX La fonction retourne une table """ dataadapter = ADOMD.AdomdDataAdapter(mdx_query, conn_string) table = DataTable() dataadapter.Fill(table) return table
def Data(self): data = DataTable() data.Columns.Add('ID', clr.GetClrType(str)) data.Columns.Add('X', clr.GetClrType(int)) data.Columns.Add('Y', clr.GetClrType(int)) data.Columns.Add('Sector', clr.GetClrType(str)) for sos in self.SOS: sector = self.GetSector(sos.x, sos.y) data.Rows.Add(hex(sos.serial), sos.x, sos.y, sector) Misc.SendMessage( '{0}: SOS Data has been loaded.'.format(self.ScriptName), 67) return data
class EzTableView(EzControl): def __init__(self, h): self.ctrl = ListView() self.table = DataTable('table') self.Initialize(h) if h.get('fontsize'): self.SetFontSize(h['fontsize']) if h.get('handler'): self.ctrl.SelectionChanged += h['handler'] self.grid = GridView() self.grid.AllowsColumnReorder = True self.grid.ColumnHeaderToolTip = "ListView Column Info" if h.get('columns'): items = h['columns'] width = None if h.get('widths'): width = h['widths'] for i in range(0, len(items)): col = GridViewColumn() col.DisplayMemberBinding = Binding(items[i]) col.Header = items[i] if width: col.Width = width[i] self.grid.Columns.Add(col) self.AddColumn(items[i]) self.ctrl.View = self.grid self.ctrl.ItemsSource = self.table.DefaultView #DataView(self.table) def AddColumn(self, label): item = DataColumn(label, GetType("System.String")) ''' column.DataType = System.Type.GetType("System.String"); column.ColumnName = "ParentItem"; column.AutoIncrement = false; column.Caption = "ParentItem"; column.ReadOnly = false; column.Unique = false; ''' self.table.Columns.Add(item) def AddItem(self, items): item = self.table.NewRow() for key, value in items.items(): item[key] = value self.table.Rows.Add(item) def GetValue(self): return self.ctrl.SelectedItem
def synthesize(S_plus, S_minus, k): """Finds a CFG with k non-terminals consistent with the input Input: a sample, S = (S_plus, S_minus), an integer k Output: a CFG (productions as the set of tuples) or None""" factors = pipe | prefixes | suffixes F = factors(S_plus | S_minus) F.remove("") context = SolverContext.GetContext() context.LoadModel(FileFormat.OML, StringReader(strModel)) parameters = context.CurrentModel.Parameters for i in parameters: if i.Name == "t": table = DataTable() table.Columns.Add("F", str) table.Columns.Add("Value", int) for f in F: table.Rows.Add(f, 1 if len(f) == 1 else 0) i.SetBinding[DataRow](AsEnumerable(table), "Value", "F") if i.Name == "u": table = DataTable() table.Columns.Add("A", str) table.Columns.Add("B", str) table.Columns.Add("C", str) table.Columns.Add("Value", int) for a in F: for b in F: for c in F: table.Rows.Add(a, b, c, 1 if len(a) == 1 and a + b == c else 0) i.SetBinding[DataRow](AsEnumerable(table), "Value", "A", "B", "C") if i.Name == "v": table = DataTable() table.Columns.Add("A", str) table.Columns.Add("B", str) table.Columns.Add("C", str) table.Columns.Add("D", str) table.Columns.Add("Value", int) for a in F: for b in F: for c in F: for d in F: table.Rows.Add( a, b, c, d, 1 if len(a) == 1 and a + b + c == d else 0) i.SetBinding[DataRow](AsEnumerable(table), "Value", "A", "B", "C", "D") if i.Name == "positives": table = DataTable() table.Columns.Add("F", str) table.Columns.Add("Value", int) for f in F: table.Rows.Add(f, 1 if f in S_plus else 0) i.SetBinding[DataRow](AsEnumerable(table), "Value", "F") if i.Name == "negatives": table = DataTable() table.Columns.Add("F", str) table.Columns.Add("Value", int) for f in F: table.Rows.Add(f, 1 if f in S_minus else 0) i.SetBinding[DataRow](AsEnumerable(table), "Value", "F") if i.Name == "dummy": table = DataTable() table.Columns.Add("K", int) table.Columns.Add("Value", int) for j in xrange(k): table.Rows.Add(j, 0) i.SetBinding[DataRow](AsEnumerable(table), "Value", "K") solution = context.Solve() if solution.Quality == SolverQuality.Optimal \ or solution.Quality == SolverQuality.LocalOptimal: for d in solution.Decisions: if d.Name == "x": x = d.GetValues() if d.Name == "y": y = d.GetValues() if d.Name == "z": z = d.GetValues() cfg = varsToCFG(x, y, z) context.ClearModel() return cfg else: context.ClearModel() return None
connection_params = { "user": "******", "password": "******", "instance": "localhost\\SQLEXPRESS" } tableName = 'test' sqlConnectionString = "Persist Security Info=False;User ID={user};Password={password};Initial Catalog=test;Server={instance}".format( **connection_params) data = fetch_sample_data() fields = ["id", "geometry"] t0 = datetime.datetime.now() tbl = DataTable() for field in fields: if type(data[0][field]) is int: tbl.Columns.Add(field, Int32) elif type(data[0][field]) is float: tbl.Columns.Add(field, Double) else: tbl.Columns.Add(field, String) for row in data: newRow = [row[x] for x in fields] tbl.Rows.Add(Array[object](newRow)) t1 = datetime.datetime.now() print("Building DataTable object: {}".format(t1 - t0))
from System.Data import SqlClient from System.Data import * from System.Data import DataTable import clr clr.AddReference('System') # from System import * clr.AddReference('System.Memory') from System import Console from System import Data sqlConnectionString = "<sql-connection-string>" sqlDbConnection = SqlClient.SqlConnection(sqlConnectionString) sqlDbConnection.Open() workTable = DataTable() workTable.Columns.Add("Col1", Byte) workTable.Columns.Add("Col2",Byte) workTable.Columns.Add("Col3", Int32) workTable.Columns.Add("Col4", Byte) workTable.Columns.Add("Col5", Byte) workTable.Columns.Add("Col6", Single) sampleArray = [Byte(7), Byte(8), Int32(1), Byte(15), Byte(12), Single(0.34324)] for i in range (0, 189000) : workTable.Rows.Add(Array[object](sampleArray)) cmd = SqlClient.SqlCommand("truncate table dbo.MyTable", sqlDbConnection); def bulkLoadEsgData (): sbc = SqlClient.SqlBulkCopy(sqlConnectionString, SqlClient.SqlBulkCopyOptions.TableLock, BulkCopyTimeout=0, DestinationTableName="dbo.MyTable") sbc.WriteToServer(workTable)
from System.Threading import Thread from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import RowSelection from Spotfire.Dxp.Data import DataValueCursor from Spotfire.Dxp.Data import DataSelection from Spotfire.Dxp.Data import DataPropertyClass from Spotfire.Dxp.Data import Import from System import DateTime from System import DateTime, TimeSpan, DayOfWeek from datetime import date from System.Net import HttpWebRequest import time from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings dataSet = DataSet() dataTable = DataTable("timelineEvents") dataTable.Columns.Add("parentType", System.String) dataTable.Columns.Add("parentId", System.String) dataTable.Columns.Add("start", System.DateTime) dataTable.Columns.Add("end", System.DateTime) dataTable.Columns.Add("eventType", System.String) dataTable.Columns.Add("desc", System.String) dataTable.Columns.Add("singleEvent", System.String) dataSet.Tables.Add(dataTable) dt = dataTable.NewRow() dt["parentType"] = "Case" dt["parentId"] = "28081" dt["start"] = "2017-08-28T15:47:01.572Z" dt["end"] = "2017-08-28T15:47:01.572Z" dt["eventType"] = "CASE_STARTER"
class ExampleAppForm(Form): _COLUMNS = [ ("Name", System.String, "name"), ("Surname", System.String, "surname"), ("Company", System.String, lambda x: x["company"]["name"]) ] def __init__(self): self.Text = "Example App" self.Name = "ExampleApp" self.ClientSize = Size(370, 400) self.MinimumSize = Size(370, 300) self._table = DataTable() self._columns = { d[0]: self._table.Columns.Add(d[0], d[1]) for d in self._COLUMNS } self._loadPanel = Panel() self._loadPanel.Location = Point(0, 0) self._loadPanel.Size = Size(215, 30) self._loadPanel.Dock = DockStyle.Top self._fileTextBoxLabel = Label() self._fileTextBoxLabel.Text = "Load file" self._fileTextBoxLabel.Size = Size(100, 16) self._fileTextBoxLabel.Location = Point(5, 7) self._loadPanel.Controls.Add(self._fileTextBoxLabel) self._fileTextBox = TextBox() self._fileTextBox.Size = Size(200, 20) self._fileTextBox.Location = Point(110, 5) self._loadPanel.Controls.Add(self._fileTextBox) self._loadButton = Button() self._loadButton.Size = Size(50, 20) self._loadButton.Location = Point(315, 5) self._loadButton.Text = "Load" self._loadPanel.Controls.Add(self._loadButton) self._dataPanel = Panel() self._dataPanel.Location = Point(0, 35) self._dataPanel.Size = Size(370, 185) self._dataGrid = DataGridView() self._dataGrid.AllowUserToOrderColumns = True self._dataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize self._dataGrid.Location = Point(0, 0) self._dataGrid.Size = Size(360, 180) self._dataGrid.DataSource = self._table self._dataPanel.Controls.Add(self._dataGrid) self.Controls.Add(self._loadPanel) self.Controls.Add(self._dataPanel) self._loadButton.Click += self.loadData def loadData(self, sender, event): filepath = self._fileTextBox.Text if not filepath or not os.path.exists(filepath): return try: contacts, meta = parseXML(filepath) except: traceback.print_exc() return for contact in contacts: row = self._table.NewRow() for col_name, __, key in self._COLUMNS: if callable(key): row[col_name] = key(contact) else: row[col_name] = contact[key] self._table.Rows.Add(row)
clr.AddReference('System.Data') clr.AddReference('System.Windows.Forms') from System.Data import DataTable from System.Data.OleDb import * from System.Windows.Forms import * from CAI.Base.NucleoCAI import * # Abre la conexión con Excel conExl = OleDbConnection( "provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\Usuario1\Desktop\prueba.xlsx; Extended Properties=Excel 12.0;" ) conExl.Open() # dtSch = conExl.GetSchema('Tables') # Matrices.Mostrar(dtSch.DefaultView()) dstExl = DataTable('frutas') cmdExl = OleDbCommand('select * from [frutas$]', conExl) adpExl = OleDbDataAdapter(cmdExl) adpExl.Fill(dstExl) # Despliega en un mensaje cada uno de los renglones del archivo for reg in dstExl.Rows: MessageBox.Show(reg['Fruta'].ToString())
def Parse(self, entry): #print "Starting to parse entry" #print entry titlename = re.search("\d*/\d*/\d*", entry.title).group(0) #print "Name of entry title is: " #print titlename if not self.ComicList.Tables.Contains(titlename): #print "Table is not yet in dataset" Application.DoEvents() #print "Creating row for WeekList but do not add it yet as it still needs the publisherlist" row2 = self.ComicList.Tables["WeekList"].NewRow() #print "Created new row in weeklist" row2["Date"] = titlename publisherlist = [] #print "Create the datatable for the list of comics" data = DataTable(titlename) id = DataColumn("ID") pub = DataColumn("Publisher") title = DataColumn("Title") price = DataColumn("Price") image = DataColumn("Image") image.DataType = System.Type.GetType('System.String') id.DataType = System.Type.GetType('System.Int32') pub.DataType = System.Type.GetType('System.String') title.DataType = System.Type.GetType('System.String') price.DataType = System.Type.GetType('System.String') data.Columns.Add(id) data.Columns.Add(pub) data.Columns.Add(title) data.Columns.Add(price) data.Columns.Add(image) #print "Finished Creating data columns" #print "Now finding the list of comics" x = HtmlAgilityPack.HtmlDocument() x.LoadHtml(entry.content) nodes = x.DocumentNode.SelectNodes("pre") #Find the largest paragraph in the source. #The largest paragraph contains the comiclist index = {"index": 0, "length": 0} comiclistNode = None for node in nodes: if comiclistNode is None or len(node.InnerText) > len( comiclistNode.InnerText): comiclistNode = node Application.DoEvents() if comiclistNode is None: print "No comic list found" return None, None #Now that we know which node the comiclist is, parse it into a csv list try: comiclist = HtmlEntity.DeEntitize(nodes[0].InnerHtml).replace( '<br>', '\n').splitlines() except Exception, ex: print ex print "Something failed" return None, None #Don't need these del (x) del (nodes) # print comiclist count = 1 #Go through all the lines in the list execpt the first one which is the definitions. for line in comiclist[1:]: try: #print count print line Application.DoEvents() #Using python list doesn't work, so use System.Array l = System.Array[str](line.strip().replace('"', '').split(',')) row = data.NewRow() date, code, publisher, title, price = l row["ID"] = count count += 1 row["Publisher"] = publisher if not publisher in publisherlist and not publisher in self.BlackList: publisherlist.append(publisher) row["Title"] = title if price: row["Price"] = price else: row["Price"] = "" row["Image"] = "" data.Rows.Add(row) except Exception, ex: #Line was not formated in the normal pattern #print ex #print type(ex) #print line continue
def get_DAX(connection_string, dax_string, remove_brackets=False): ''' Executes DAX query and returns the results as a pandas DataFrame Parameters --------------- connection_string : string Valid SSAS connection string, use the set_conn_string() method to set dax_string : string Valid DAX query, beginning with EVALUATE or VAR or DEFINE remove_brackets : boolean If True, then removes brackets from column names Returns ---------------- pandas DataFrame with the results ''' dataadapter = ADOMD.AdomdDataAdapter(dax_string, connection_string) table = DataTable() logger.info('Getting DAX query...') try: dataadapter.Fill(table) except Exception as ex: logger.exception('Exception occured:\n') sys.exit(1) col_names = [] for c in table.Columns.List: col_names.append(c.ColumnName) num_rows = table.Rows.Count d = {} for r in range(num_rows): row_dict = {} for c in table.Columns.List: if isinstance(table.Rows[r][c], System.DBNull): row_dict[c.ColumnName] = None elif isinstance(table.Rows[r][c], System.DateTime): row_dict[c.ColumnName] = pd.Timestamp( table.Rows[r][c].ToShortDateString()) else: row_dict[c.ColumnName] = table.Rows[r][c] d[r] = row_dict df = pd.DataFrame.from_dict(d, orient='index') # remove brackets from column names if remove_brackets: def remove_brackets(col): x = col if x[0] == '[': x = x.replace('[', '') x = x.replace('[', '_') x = x.replace(']', '') return x df = df.rename(columns=remove_brackets) logger.info('DAX query successfully retrieved') return df