please help...writing set to a file
Good day every one! I got this python program that returns me a set like this.. Set ([‘A\n’, B\n’, ‘C\n’, ‘D\n’, ‘E\n’, ‘F\n’, ‘G\n’ ]) And a list pp = [‘100\n’ ‘200\n’ ‘300\n’ ‘400\n’] I was reading this from a file…. How can I transform this to something that looks like this Column1 Column 2 100 A 200 B 300 C 400D E F G And then write this to a file??? thank you for taking your time!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: finding repeated data sequences in a column
On May 20, 6:53 pm, norseman wrote: > bearophileh...@lycos.com wrote: > > yadin: > >> How can I build up a program that tells me that this sequence > >> 128706 > >> 128707 > >> 128708 > >> is repeated somewhere in the column, and how can i know where? > > > Can such patterns nest? That is, can you have a repeated pattern made > > of an already seen pattern plus something else? > > If you don't want a complex program, then you may need to specify the > > problem better. > > > You may want something like LZ77 or releated (LZ78, etc): > >http://en.wikipedia.org/wiki/LZ77 > > This may have a bug: > >http://code.activestate.com/recipes/117226/ > > > Bye, > > bearophile > > > index on column > Ndx1 is set to index #1 > Ndx2 is set to index #2 > test Ndx1 against Ndx2 > if equal write line number and column content to a file > (that's two things on one line: 15 128706 > 283 128706 ) > Ndx1 is set to Ndx2 > Ndx2 is set to index #next > loop to test writing out each duplicate set > > Then use the outfile and index on line number > > In similar manor, check if line current and next line line numbers are > sequential. If so scan forward to match column content of lower line > number and check first matched column's line number and next for > sequential. Print them out if so > > everything in outfile has 1 or more duplicates > > 4 aa |-- > 5 bb |-- | thus 4/5 match 100/101 > 6 cc | | > . | | > 100 aa | |-- > 101 bb |-- > 102 ddd > 103 cc there is a duplicate but not a sequence > 200 ff > > mark duplicate sequences as tested and proceed on through > seq1 may have more than one other seq in file. > the progress is from start to finish without looking back > thus each step forward has fewer lines to test. > marking already knowns eliminates redundant sequence testing. > > By subseting on pass1 the expensive testing is greatly reduced. > If you know your subset data won't exceed memory then the "outfile" > can be held in memory to speed things up considerably. > > Today is: 20090520 > no code > > Steve- Hide quoted text - > > - Show quoted text - this is the program...I wrote but is not working I have a list of valves, and another of pressures; If I am ask to find out which ones are the valves that are using all this set of pressures, wanted best pressures this is the program i wrote but is not working properly, it suppossed to return in the case find all the valves that are using pressures 1 "and" 2 "and" 3. It returns me A, A2, A35 The correct answer supposed to be A and A2... if I were asked for pressures 56 and 78 the correct answer supossed to be valves G and G2... Valves = ['A','A','A','G', 'G', 'G', 'C','A2','A2','A2','F','G2','G2','G2','A35','A345','A4'] ##valve names pressures = [1,2,3,4235,56,78,12, 1, 2, 3, 445, 45,56,78,1, 23,7] ## valve pressures result = [] bestpress = [1,2,3] ##wanted base pressures print bestpress,'len bestpress is' , len(bestpress) print len(Valves) print len(Valves) for j in range(len(Valves)): #for i in range(len(bestpress)): #for j in range(len(Valves)): for i in range(len(bestpress)-2): if pressures [j]== bestpress[i] and bestpress [i+1] ==pressures [j+1] and bestpress [i+2]==pressures [j+2]: result.append(Valves[j]) #i = i+1 #j = j+1 # print i, j, bestpress[i] print "common PSVs are", result -- http://mail.python.org/mailman/listinfo/python-list
Re: finding repeated data sequences in a column
On May 20, 11:16 am, bearophileh...@lycos.com wrote: > yadin, understanding what you want is probably 10 times harder than > writing down the code :-) > > > I have a a table, from where I can extract a column. > > You can extract it? Or do you want to extract it? Or do you want to > process it? Etc. > > > I wanna go down trough that column made of numbers > > examine undetermined chunks ofdataand see or detect if that sequence > > of chunk > > ofdatahas beenrepeatedbefore > > What do you mean by "undetermined"? What kind ofdata? Where is thisdata? How > is this "chunk" shaped? Are you talking about a string? > > > and if it has beenrepeateddetect it by giving it a name in an > > adjacent column. > > What kind of name? So you just need 2 names, like N and S for New and > Seen? > You can use a built-in setdatastructure to know if you have already > seen somedata, while you scan the records. > > > Imagine someting like this but made of 1800 numbers... > > How are such 1800 disposed? Do you mean 1800 columns of 32 bit > numbers? > > > how can I build up column 3(category)< > > What does A, B and C mean? > > Bye, > bearophile lets say you have this column of numbers 128706 128707 128708 100 12 128706 128707 128708 128709 128706 128707 128708 100 12 6 How can I build up a program that tells me that this sequence 128706 128707 128708 is repeated somewhere in the column, and how can i know where? thank you very much! -- http://mail.python.org/mailman/listinfo/python-list
finding repeated data sequences in a column
Good day everyone! I have a a table, from where I can extract a column. I wanna go down trough that column made of numbers examine undetermined chunks of data and see or detect if that sequence of chunk of data has been repeated before and if it has been repeated detect it by giving it a name in an adjacent column. Imagine someting like this but made of 1800 numbers... how can I build up column 3(category) Itemprice Category 400 128706 A 400 128707 A 400 128708 A 101 100 C 101 12 C 500 128706 A 500 128707 A 500 128708 A 500 128709 B 120 128706 A 120 128707 A 120 128708 A 120 100 C 120 12 C -- http://mail.python.org/mailman/listinfo/python-list
xyz points and magnitude to intensity or colormap or contourmap
hi! how do you do contour maps with vtk? i have 3600 points for each point i have a corresponding magnitude. i plane to do contour maps that is i plot each point with a different color (representing its magnitude ) how can i do this with using python, matplotlib or vtk? does any one have a similar example please any thing to start wiht wil be good thanks -- http://mail.python.org/mailman/listinfo/python-list
developing an application
hi! i was buiding an application using python...a program this was my first one...now that i got it working perfectly how can i put the bunch of files into one package? the user of the appliation will not know where to start? that is which file to click on in oder to start the program? thanks a lot -- http://mail.python.org/mailman/listinfo/python-list
building a GUI
if i were up to make a GUI chich are the advantages of choosing python over matlab or java? -- http://mail.python.org/mailman/listinfo/python-list
sentance containg the string or symbol Ω
how can i print a sentance containg the string or symbol Ω in python and also lambda? -- http://mail.python.org/mailman/listinfo/python-list
3D plot of 50 lines kwing end points using VTK
does anyone know how to plot multimple lines like lets say... 50 lines each liine is defined beetween two given points using VTK. a litlle example will be ok please on python and VTK thank you -- http://mail.python.org/mailman/listinfo/python-list
help on object programing
class big(self): x = 32 list = [] def inside (self): class small(self): # a new class defined inside the first y = 348 list.append(y) # send the value to first list list.append(x) print list how can i define my variables so that there are valid outside the class??? -- http://mail.python.org/mailman/listinfo/python-list
help to make program better
hi! Can any one tell me why is it that i can't see my second frame and why is the value of freq not Appended in the First frame ...thanks I know it is wx python but it has to do with passing variables.thanks import wx def create(parent): return Frame1(parent) [wxID_FRAME1, wxID_FRAME1FREQ, wxID_FRAME1FREQDISP, wxID_FRAME1STATICTEXT1, ] = [wx.NewId() for _init_ctrls in range(4)] class Frame1(wx.Frame): def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(380, 179), size=wx.Size(241, 133), style=wx.DEFAULT_FRAME_STYLE, title='Frame1') self.SetClientSize(wx.Size(233, 99)) self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, label='frequency disp', name='staticText1', parent=self, pos=wx.Point(24, 32), size=wx.Size(71, 13), style=0) self.freqdisp = wx.TextCtrl(id=wxID_FRAME1FREQDISP, name='freqdisp', parent=self, pos=wx.Point(104, 24), size=wx.Size(100, 21), style=0, value='') self.freq = wx.Button(id=wxID_FRAME1FREQ, label='get freq', name='freq', parent=self, pos=wx.Point(24, 56), size=wx.Size(184, 23), style=0) self.freq.Bind(wx.EVT_BUTTON, self.OnButton1Button, id=wxID_FRAME1FREQ) def __init__(self, parent): self._init_ctrls(parent) def OnButton1Button(self, event): def create(parent): return Frame2(parent) [wxID_FRAME2, wxID_FRAME2FREQ, wxID_FRAME2FREQDISP, wxID_FRAME2STATICTEXT1,] = [wx.NewId() for _init_ctrls in range(4)] class Frame2: def __init__(self): # wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prt, pos=wx.Point(400, 179), size=wx.Size(300, 133), style=wx.DEFAULT_FRAME_STYLE, title='Frame2') self.SetClientSize(wx.Size(233, 99)) self.staticText1 = wx.StaticText(id=wxID_FRAME2STATICTEXT1, label='frequency goes here first', name='staticText2', parent=self, pos=wx.Point(24, 32), size=wx.Size(71, 13), style=0) self.freqdisp2 = wx.TextCtrl(id=wxID_FRAME2FREQDISP, name='freqdisp2', parent=self, pos=wx.Point(104, 24), size=wx.Size(100, 21), style=0, value=' ') self.freq = wx.Button(id=wxID_FRAME2FREQ, label='get freq', name='freq', parent=self, pos=wx.Point(24, 56), size=wx.Size(184, 23), style=0) self.freq.Bind(wx.EVT_BUTTON, self.OnButton2Button, id=wxID_FRAME2FREQ) def __init__(self, parent): self._init_ctrls(parent) def OnButton2Button(self, event): freqdisp.Append('this is it 24HZ!') Show() if __name__ == '__main__': app = wx.PySimpleApp() frame = create(None) frame.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
help to make program better
hi! Can any one tell me why is it that i can't see my second frame and why is the value of freq not Appended in the First frame ...thanks I know it is wx python but it has to do with passing variables.thanks import wx def create(parent): return Frame1(parent) [wxID_FRAME1, wxID_FRAME1FREQ, wxID_FRAME1FREQDISP, wxID_FRAME1STATICTEXT1, ] = [wx.NewId() for _init_ctrls in range(4)] class Frame1(wx.Frame): def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(380, 179), size=wx.Size(241, 133), style=wx.DEFAULT_FRAME_STYLE, title='Frame1') self.SetClientSize(wx.Size(233, 99)) self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, label='frequency disp', name='staticText1', parent=self, pos=wx.Point(24, 32), size=wx.Size(71, 13), style=0) self.freqdisp = wx.TextCtrl(id=wxID_FRAME1FREQDISP, name='freqdisp', parent=self, pos=wx.Point(104, 24), size=wx.Size(100, 21), style=0, value='') self.freq = wx.Button(id=wxID_FRAME1FREQ, label='get freq', name='freq', parent=self, pos=wx.Point(24, 56), size=wx.Size(184, 23), style=0) self.freq.Bind(wx.EVT_BUTTON, self.OnButton1Button, id=wxID_FRAME1FREQ) def __init__(self, parent): self._init_ctrls(parent) def OnButton1Button(self, event): def create(parent): return Frame2(parent) [wxID_FRAME2, wxID_FRAME2FREQ, wxID_FRAME2FREQDISP, wxID_FRAME2STATICTEXT1,] = [wx.NewId() for _init_ctrls in range(4)] class Frame2: def __init__(self): # wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prt, pos=wx.Point(400, 179), size=wx.Size(300, 133), style=wx.DEFAULT_FRAME_STYLE, title='Frame2') self.SetClientSize(wx.Size(233, 99)) self.staticText1 = wx.StaticText(id=wxID_FRAME2STATICTEXT1, label='frequency goes here first', name='staticText2', parent=self, pos=wx.Point(24, 32), size=wx.Size(71, 13), style=0) self.freqdisp2 = wx.TextCtrl(id=wxID_FRAME2FREQDISP, name='freqdisp2', parent=self, pos=wx.Point(104, 24), size=wx.Size(100, 21), style=0, value=' ') self.freq = wx.Button(id=wxID_FRAME2FREQ, label='get freq', name='freq', parent=self, pos=wx.Point(24, 56), size=wx.Size(184, 23), style=0) self.freq.Bind(wx.EVT_BUTTON, self.OnButton2Button, id=wxID_FRAME2FREQ) def __init__(self, parent): self._init_ctrls(parent) def OnButton2Button(self, event): freqdisp.Append('this is it 24HZ!') if __name__ == '__main__': app = wx.PySimpleApp() frame = create(None) frame.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
passing variables and values to texboxdisplays
hi! Can any one tell me why is it that i can't see my second frame and why is the value of freq not Appended in the First frame ...thanks I know it is wx python but it has to do with passing variables.thanks import wx def create(parent): return Frame1(parent) [wxID_FRAME1, wxID_FRAME1FREQ, wxID_FRAME1FREQDISP, wxID_FRAME1STATICTEXT1, ] = [wx.NewId() for _init_ctrls in range(4)] class Frame1(wx.Frame): def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(380, 179), size=wx.Size(241, 133), style=wx.DEFAULT_FRAME_STYLE, title='Frame1') self.SetClientSize(wx.Size(233, 99)) self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, label='frequency disp', name='staticText1', parent=self, pos=wx.Point(24, 32), size=wx.Size(71, 13), style=0) self.freqdisp = wx.TextCtrl(id=wxID_FRAME1FREQDISP, name='freqdisp', parent=self, pos=wx.Point(104, 24), size=wx.Size(100, 21), style=0, value='') self.freq = wx.Button(id=wxID_FRAME1FREQ, label='get freq', name='freq', parent=self, pos=wx.Point(24, 56), size=wx.Size(184, 23), style=0) self.freq.Bind(wx.EVT_BUTTON, self.OnButton1Button, id=wxID_FRAME1FREQ) def __init__(self, parent): self._init_ctrls(parent) def OnButton1Button(self, event): def create(parent): return Frame2(parent) [wxID_FRAME2, wxID_FRAME2FREQ, wxID_FRAME2FREQDISP, wxID_FRAME2STATICTEXT1,] = [wx.NewId() for _init_ctrls in range(4)] class Frame2: def __init__(self): # wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prt, pos=wx.Point(400, 179), size=wx.Size(300, 133), style=wx.DEFAULT_FRAME_STYLE, title='Frame2') self.SetClientSize(wx.Size(233, 99)) self.staticText1 = wx.StaticText(id=wxID_FRAME2STATICTEXT1, label='frequency goes here first', name='staticText2', parent=self, pos=wx.Point(24, 32), size=wx.Size(71, 13), style=0) self.freqdisp2 = wx.TextCtrl(id=wxID_FRAME2FREQDISP, name='freqdisp2', parent=self, pos=wx.Point(104, 24), size=wx.Size(100, 21), style=0, value=' ') self.freq = wx.Button(id=wxID_FRAME2FREQ, label='get freq', name='freq', parent=self, pos=wx.Point(24, 56), size=wx.Size(184, 23), style=0) self.freq.Bind(wx.EVT_BUTTON, self.OnButton2Button, id=wxID_FRAME2FREQ) def __init__(self, parent): self._init_ctrls(parent) def OnButton2Button(self, event): freqdisp.Append('this is it 24HZ!') if __name__ == '__main__': app = wx.PySimpleApp() frame = create(None) frame.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
ploting issues in program
hi every one! can you please help me to fix these polar plot in db's so that the center is at the minimun negative number in voltagedb about [-50] and the maximun is at zero and how can i see values on the axis like showing that the axes start at -50 -40 -30 .and end at zero than you here is the program import wx import os from wx.lib.colourdb import * from pylab import* angteta = [ 4.36332313e-003, 3.18522588e-001, 6.32681854e-001, 9.46841119e-001, 1.26100038e+000, 1.57515965e+000, 1.88931892e+000, 2.20347818e+000, 2.51763745e+000, 2.83179671e+000, 3.14595598e+000, 3.46011524e+000, 3.77427451e+000, 4.08843377e+000, 4.40259304e+000, 4.71675230e+000, 5.03091157e+000, 5.34507083e+000, 5.65923010e+000, 5.97338936e+000,] voltage = [ 0.00363471, 0.26569155, 0.52562334, 0.76330428, 0.93673361, 1., 0.93321713, 0.75733232, 0.5185449 , 0.25840091, 0.00363471, 0.26569155, 0.52562334, 0.76330428, 0.93673361, 1., 0.93321713, 0.75733232, 0.5185449 , 0.25840091,] #voltagedb = 20*log10(voltage) voltagedb = [-48.7906044 ,-11.51244516, -5.58650713, -2.34604603, -0.56767793, 0., -0.60034598, -2.41427014, -5.7042726 ,-11.75411924,-48.7906044 , -11.51244516, -5.58650713, -2.34604603, -0.56767793, 0., -0.60034598, -2.41427014, -5.7042726 ,-11.75411924,] polar(angteta,voltagedb) show() -- http://mail.python.org/mailman/listinfo/python-list
negative values on polar plot (decibels polar plots )
hi every one can you please can you help me to fix these polar plot in db's so that the center is at the minimun negative number in voltagedb about [-50] and the maximun is at zero how can i see values on the axies like showing that the axes start at -40 -30 .0 than you import wx import os from wx.lib.colourdb import * from pylab import* angteta = [ 4.36332313e-003, 3.18522588e-001, 6.32681854e-001, 9.46841119e-001, 1.26100038e+000, 1.57515965e+000, 1.88931892e+000, 2.20347818e+000, 2.51763745e+000, 2.83179671e+000, 3.14595598e+000, 3.46011524e+000, 3.77427451e+000, 4.08843377e+000, 4.40259304e+000, 4.71675230e+000, 5.03091157e+000, 5.34507083e+000, 5.65923010e+000, 5.97338936e+000,] voltage = [ 0.00363471, 0.26569155, 0.52562334, 0.76330428, 0.93673361, 1., 0.93321713, 0.75733232, 0.5185449 , 0.25840091, 0.00363471, 0.26569155, 0.52562334, 0.76330428, 0.93673361, 1., 0.93321713, 0.75733232, 0.5185449 , 0.25840091,] #voltagedb = 20*log10(voltage) voltagedb = [-48.7906044 ,-11.51244516, -5.58650713, -2.34604603, -0.56767793, 0., -0.60034598, -2.41427014, -5.7042726 ,-11.75411924,-48.7906044 , -11.51244516, -5.58650713, -2.34604603, -0.56767793, 0., -0.60034598, -2.41427014, -5.7042726 ,-11.75411924,] polar(angteta,voltagedb) show() -- http://mail.python.org/mailman/listinfo/python-list
about negative polar plots not defined in python not even matlab
high i think everybody has seen dB radiation pattern plots... well those are done with negative polar plots ...the values of the magnitude in the axes are NEGATIVE values... but i can find a polar plot command that those negative plots not in python not even in matlab the polar plots represents the value of the power radiated in dB's and the dB's go from -40dB to 0dB as the angle theta changes from 0 to 2*pi rads the polar plot in python goes with positive values how can i solve this problem rough example example: power = arange(-40,0,-10) theta = arange(0, 2pi,pi/12) polar(power,theta) title.? how can i show the step on the polar plot plot(-40, -30,-20,-10,0) -- http://mail.python.org/mailman/listinfo/python-list
about negative polar plots
hi am doing a polar plot of the radiation pattern of an antenna. the polar plots represents the value of the power in dB's and the dB go from -40dB to 0dB as the angle theta changes from 0 to 2*pi rads the polar plot in python goes with positive values how can i solve this problem rough example example: power = arange(-40,0,-10) theta = arange(0, 2pi,pi/12) polar(power,theta) title.? how can i show the step on the polar plot plot(-40, -30,-20,-10,0) -- http://mail.python.org/mailman/listinfo/python-list
negative polar axis
hi! how can i do polar plot in python with negative axes that is the value of the magnitude is negative -- http://mail.python.org/mailman/listinfo/python-list
how to add a toolbar to a Frame using wxpython
hi please am learning wxpython and I Need help on getting examles of how to create a toolbar with images that is add a toolbar to a Frame using wxpython using wxpython on a windows pc how can i add a toolbar to a GUI all sample codes i could find contain errors. i did the following but it is wrong! my biggest trouble seems to be with the IMAGES? do i have to create them, load them...? or they come with python like in Matlab thank you. import wx from pylab import* class MainWindow(wx.Frame): def __init__(self,parent,id,title): self.dirname='' wx.Frame.__init__(self,parent,wx.ID_ANY, title,wx.DefaultPosition, wx.Size(320,410)) ##___ADDING A TOOLBAR___## toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER) toolbar.AddSimpleTool(1, wx.Image('stock_new.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '') toolbar.Realize() Frame.Add(toolbar, 0, border=5) app = wx.PySimpleApp() frame = MainWindow(None, -1, " dipole antenna ") frame.show(1) frame.SetBackgroundColour('light grey') app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
create a toolbar + images using wxpython for windows
hi everery one I Need help on getting examles of how to create a toolbar with images using wxpython on a windows pc how can i add a toolbar to a GUI all sample codes i could find contain errors. i did the following but it is wrong! what is it with the IMAGES? do i have to create them, load them...? or they come with python like in Matlab thank you. import wx from pylab import* class MainWindow(wx.Frame): def __init__(self,parent,id,title): self.dirname='' wx.Frame.__init__(self,parent,wx.ID_ANY, title,wx.DefaultPosition, wx.Size(320,410)) ##___ADDING A TOOLBAR___## toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER) toolbar.AddSimpleTool(1, wx.Image('stock_new.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '') toolbar.Realize() Frame.Add(toolbar, 0, border=5) app = wx.PySimpleApp() frame = MainWindow(None, -1, " dipole antenna ") frame.show(1) frame.SetBackgroundColour('light grey') app.MainLoop() __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.espanol.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
link between python and the windows command prompt
hi! i need to know how i can run ussal commands that i ussally type at the windows command prompt from a python file. that is for example from the windows command prompt i ussually type "cd D:\folder\ nec2++ - i inputfile.nec -o outputfile.out " now how can i execute this command that i ussually type at the windows command prompt from a python file? i know it has to do with the sys and os module but how specifically? what commands? any references? -- http://mail.python.org/mailman/listinfo/python-list