Extract half screen of a video
Hello Guys, I have a video and what I want is to extract only half of the screen of it.By half screen i mean when i run the video i can say the left half(from the monitor's screen) of the video and dump the right half. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Mencoder not working from a python script
Hello guys, I am trying to create a python script which uses mencoder to create videos from a set of images.When I am using the command(windows 7) i am able to generate the video properly.But when used within a python script i am ggetting error.Below is the code and error.any help is appreciated. import *subprocess*,*sys*,os def *createVideo*(): mencoder = *C:\\MPlayer-p4-svn-30075\\mencoder.exe* path=*mf://\C:\\videos\\test\\*.jpg\ * output=*\C:\\videos\\test\\xyz.avi\* commande = *%s %s -mf w=800:h=600:fps=25:type=jpg -ovc copy -oac copy -o %s* os.system(commande % (mencoder, path,output)) if __name__==*__main__*: createVideo() error- MEncoder Sherpya-SVN-r30075-4.2.5 (C) 2000-2009 MPlayer Team success: format: 16 data: 0x0 - 0x0 MF file format detected. [mf] search expr: C:\cameras\Perkins Road\*.jpg [mf] number of files: 301 (1204) VIDEO: [IJPG] 800x600 24bpp 25.000 fps 0.0 kbps ( 0.0 kbyte/s) [V] filefmt:16 fourcc:0x47504A49 size:800x600 fps:25.000 ftime:=0.0400 videocodec: framecopy (800x600 24bpp fourcc=47504a49) Writing index... Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Video stream: nan kbit/s (-2147483648 B/s) size: 0 bytes 0.000 secs 0 frames Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Mencoder and creating videos
Hello Guys, I have a multiprocessing script which downloads images from 5 urls to 5 directories(usinf multiprocess in python 2.6).The download is for 5 mins.My aim is to create a video for every minute for each directory and dump the images as the video is created. My question are , should i use *mencoder.exe * to create the videos? and how should i create the videos without interrupting the download. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Do I have to use threads?
Hello people, I have 5 directories corresponding 5 different urls .I want to download images from those urls and place them in the respective directories.I have to extract the contents and download them simultaneously.I can extract the contents and do then one by one. My questions is for doing it simultaneously do I have to use threads? Please point me in the right direction. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re: Do I have to use threads?
Thanks.i will look into multiprocessing. Aditya -- http://mail.python.org/mailman/listinfo/python-list
Question-Answer based web App
Merry christmas guys, I am trying to make a web based application which has a set of questions and answers associated with it such that a report is generated based on the answers a user chooses for each question.It's like facebook apps where we have questions , answers and reports . Should i generate the report using if-else ?.Please suggest a better approach. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Live Video Capture using Python
Hello Guys, I am trying to capture images from a live broadcast of a cricket match or say any video using python. I can see the video in the browser.My aim is to capture the video at any moment and create an images.Searching on google turns up http://videocapture.sourceforge.net/ .I am not sure if this would be help here.I would appreciate if someone points me in the right direction. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Inserting into a database
Hello Guy's I am using python 2.6 on windows 7 and MySQLdb to make connections to the database.The issue here is that I am not able to insert from the python script to the database.When I run the same query in mysql query brower then the insert statement works .I am able to select from the database using the python script.The connection is fine.I am using Aptana to write the python script. I thought this could be a problem of the collation or character set problem the default character set of the system is cp1252 which corrosponds to latin_1 on mysql , I have chosen that and still no help. Any help is appreciated. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re: Inserting into a database
Hello Guys I am using python 2.6 on windows 7 and MySQLdb to make connections to the database.The issue here is that I am not able to insert from the python script to the database.When I run the same query in mysql query brower then the insert statement works .I am able to select from the database using the python script.The connection is fine.I am using Aptana to write the python script. I thought this could be a problem of the collation or character set problem the default character set of the system is cp1252 which corrosponds to latin_1 on mysql , I have chosen that and still no help. Any help is appreciated. this what the code looks like. db = MySQLdb.connect(localhost,root,juventus12,factoids,charset = utf8, use_unicode = True ) cursor= db.cursor() # i added charset = utf8, use_unicode = True just now and changed the character set of mysql still no help. cursor.execute(INSERT INTO question_table (question_id,source_id,question) VALUES (5,1,question)) language, output_encoding = locale.getdefaultlocale() print output_encoding, language traceback C:\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet cp1252 en_US Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re: Inserting into a database
On Sun, Oct 11, 2009 at 5:06 PM, aditya shukla adityashukla1...@gmail.comwrote: Hello Stephen, I have put the code and the traceback.Can you please help me now? .I am scratching my head :) I am using python 2.6 on windows 7 and MySQLdb to make connections to the database.The issue here is that I am not able to insert from the python script to the database.When I run the same query in mysql query brower then the insert statement works .I am able to select from the database using the python script.The connection is fine.I am using Aptana to write the python script. I thought this could be a problem of the collation or character set problem the default character set of the system is cp1252 which corrosponds to latin_1 on mysql , I have chosen that and still no help. Any help is appreciated. this what the code looks like. db = MySQLdb.connect(localhost,root,juventus12,factoids,charset = utf8, use_unicode = True ) cursor= db.cursor() # i added charset = utf8, use_unicode = True just now and changed the character set of mysql still no help. cursor.execute(INSERT INTO question_table (question_id,source_id,question) VALUES (5,1,question)) language, output_encoding = locale.getdefaultlocale() print output_encoding, language traceback C:\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet cp1252 en_US Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Changing IP's and Connecting to a site
Hello Guys' I have a script which i am using to do interaction with a website.Is there a way by which i can connect to the site through different ip's .Say use a proxy or something. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
KeyBoard interrupt and Redirection operator
Hello Guys, I have a program which i use like this scraps.py arg1 arg2 filename. I am using the redirection operator to direct the output to the filename .The scenario here is that I want to print a message as long as the program is running and as generate an error message and exit as I use a keyboard interrupt.I am able to do this by using a try except clause but the issue is that everything is written to the file as i am using the redirection operator .Is there a way to write the running program message and the terminate program mesage to the console without writing it to the file. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Site Scarpping with Beautiful Soup
Hello Guys, I would like to scrap a site by using Beautiful Soup library.The site has various options listed in a drop down menu.What I want to do is pass the drop down option with the python script and scrap the result obtained for each value.Let's say we have three values i the drop down menu man , gorilla and ape .I can pass scrap.py man and with that I shoud be able to scrap to all results that show up under the man category.Say african, asian , cacusian etc. My issue is that I can scrap a single page wit Beautiful Soup but have no idea of how to accomplish the above task.Please guide me in the right direction. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Temporary file
I am trying to create a temporary file. import tempfile temp = tempfile.NamedTemporaryFile(suffix='_suffix', prefix='prefix_', dir='/tmp', ) try: print 'temp:', temp print 'temp.name:', temp.name finally: temp.close() But when i do ls /tmp or ls -a /tmp i cannot find the file or if i try to os.remove(temp.name) it shows a message that the file is not found.But print temp and print temp.name show temp: open file 'fdopen', mode 'w+b' at 0xb7e84800 temp.name: /home/swamp2/cacsgrad/axs9347/Desktop/prefix_zOfoX__suffix Please help me to fix it. Aditya -- http://mail.python.org/mailman/listinfo/python-list
pyparse
Hello guys i am trying to make a simple sql parser and i found pyparse , my question here is does it return a data structure like an abstract syntax tree of the sql query.Any help is appreciated Aditya -- http://mail.python.org/mailman/listinfo/python-list
String manipulation using RE
Hello folks, i have a string eg (((A:1,B:1):3,C:3):4,((E:1,F:1):2,D:2):4) now i have to convert this string to (((A:1,B:1):2,C:3):1,((E:1,F:1):1,D:2):2) So i used the logic eg. taking the substring 1):3 and converting it to 1):2(3-1=2) so on for all the similar substrings.But i am not able to replace them back into the original string. This is what my code looks like import re str = (((A:1,B:1):3,C:3):4,((E:1,F:1):2,D:2):4) p =re.compile('\d\):\d') # compiling an re object list1 =[] iterator = p.finditer(str) for match in iterator: x = match.group() l = x.split('):') value = int(l[1])-int(l[0]) z= repr(value) rm = l[1] x= x.rstrip(rm) y = x + repr(value) print y I am able to get the desired output further, any help is appreciated Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Selecting random elements from a list.
Hello folks, i have a list say list1=[a,b,c,...z] ie 26 elements i have to take 5 elements from it randomly and save in another list.Please explain how to do this? Aditya -- http://mail.python.org/mailman/listinfo/python-list
RE module question
Hello folks : i have a string -bin-ulockmgr_server:0.99[NHX:C=0.195.0] from which i want to delete [NHX:C=0.195.0] . I wrote a regular expression for [NHX:C=0.195.0] as \[(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.)+\d\] now when i do p = re.compile('\[(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.)+\d\]') m =p.search(-bin-ulockmgr_server:0.99[NHX:C=0.195.0]) print m _sre.SRE_Match object at 0x01314EE8 print m.group() [NHX:C=0.195.0] So i guess i am able to find the substring , my question is how can i delete this substring from the original string? ie -bin-ulockmgr_server:0.99 should be my output. thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Regular expressions question
Hello folks , I trying to match a pattern in a string , i am new in using re .This is what is happening When i do this p = re.compile('(\[NHX:)') m = p.match([NHX:C=0.195.0]) print m _sre.SRE_Match object at 0x013FE1E0 --- thus i am able to find the match but when i use the string m = p.match(-bin-ulockmgr_server:0.99[NHX:) print m None -i am not able to find the match . Can someone help me here. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Parser Module
Hello folks , I wanna create a parser for newick files which generates an ultrametric tree - every leaf is equidistant from the root eg -( http://www.icp.be/~opperd/private/upgma.htmlhttp://www.icp.be/%7Eopperd/private/upgma.html) as the parse tree.Can this type of a parse tree be constructed?And what parser module should i use? Aditya -- http://mail.python.org/mailman/listinfo/python-list
File modifications
Hello folks , I have a file like this /T_0_size=105((-bin-ulockmgr_server:0.99[NHX:C=0.195.0],(((-bin-hostname:0.00 [NHX:C=200.0.0], (-bin-dnsdomainname:0.00[NHX:C=200.0.0],(-bin-domainname:0.00[NHX:C=200.0.0],(-bin-nisdomainname:0.00[NHX:C=200.0.0],-bin-ypdomainname:0.00[NHX:C=200.0.0]):0.00):0.00):0.00):0.98 ,(-bin-iptables-xml:0.97[NHX:C=0.183.0],(-bin-dbus-send:0.78[NHX:C=0.94.0],-bin-dbus-monitor:0.78[NHX:C=0.94.0]):0.97):0.98):0.99. I wanna get the file in this format ((-bin-ulockmgr_server:0.99,(((-bin-hostname:0.00,(-bin-dnsdomainname:0.00,(-bin-domainname:0.00,(-bin-nisdomainname:0.00,-bin-ypdomainname:0.00):0.00):0.00):0.00):0.98 ,(-bin-iptables-xml:0.97,(-bin-dbus-send:0.78,-bin-dbus-monitor:0.78):0.97):0.98):0.99 ie , remove /T_0_size , [NHC:C=0.195.0] , [NHX:C=200.0.0] and so on , how should i handle this after reading the file? Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Classes and functions.
Hello folks , i am using the newick module http://www.daimi.au.dk/~mailund/newick.html.I am just learning to use it and i have a question about it. from newick.tree import parse_tree from newick.tree import add_parent_links from newick.tree import add_distance_from_root import sys t = parse_tree('((A:2,B:3):1,C:6);') print t deltas = add_distance_from_root(t) now when i do this i can get the output like this (('A' : 2.0, 'B' : 3.0) : 1.0, 'C' : 6.0) None This is the code of the add_distance_from_root(0 def add_distance_from_root(tree): '''Extend all nodes with the distance (branch length) from the root''' tree.distance_from_root = 0.0 # 'tree' is the root... class V(TreeVisitor): def pre_visit_edge(self,src,b,l,dst): if l is None: l = 0 dst.distance_from_root = src.distance_from_root - l tree.dfs_traverse(V()) From here it is clear that the function does not return anything but i wanna get the value of the distance from root.How can i get this? Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Newick parser
Hello folks , i have a .nwk file.I want to parser the tree from that file.I found this python parser for newick trees. http://www.daimi.au.dk/~mailund/newick.html But i don't understand the usage properly.What i wanna do is if i have a file in the location c:\\files\\file1.nwk , then i wanna parse the trees in that file. Please help me if someone has experience on how to use this module. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Adding environment variables to bash.
Hello folks Can i add any environment variable to bash from my python script? so that when i use env command then i can see that environment variable. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
File operations
Hello folks, I am using Python-2.5.2 on fedora 9 sulphur -2.6.25-14.fc9.i686.I am creating a temporary file , in which data is written by another program and then i am using that temporary file to do my computations.I am new to linux and i am facing two issues homedir = os.path.expanduser('~') temp = tempfile.NamedTemporaryFile( suffix='_suffix',prefix='prefix_',dir= homedir) temp.close() tn = temp.name print tn Issue1 - when i am logged in as root then everything works fine except that the file is created in the current working directory (/usr/Python-2.5.2) and not in the directory supplied as the dir='directory' parameter.i have tried dir='/tmp' as well.i don't know how to fix this issue and why the file is not getting created in the specified directory. Issue2 - when i am logged in as user ie any other user than root then i get this error sh: prefix_u92XQJ_suffix: Permission denied also , i cannot find the find in either the current working directory nor in the dir='directory'.so i cant check the permission by using ls -l prefix_u92XQJ_suffix Please help me understand this issue and eventually fix it. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
tempfile module
Hello folks, I am using Python-2.5.2 on fedora 9 sulphur -2.6.25-14.fc9.i686.I am creating a temporary file , in which data is written by another program and then i am using that temporary file to do my computations.I am new to linux and i am facing two issues homedir = os.path.expanduser('~') temp = tempfile.NamedTemporaryFile( suffix='_suffix',prefix='prefix_',dir= homedir) temp.close() tn = temp.name print tn Issue1 - when i am logged in as root then everything works fine except that the file is created in the current working directory (/usr/Python-2.5.2) and not in the directory supplied as the dir='directory' parameter.i have tried dir='/tmp' as well.i don't know how to fix this issue and why the file is not getting created in the specified directory. Issue2 - when i am logged in as user ie any other user than root then i get this error sh: prefix_u92XQJ_suffix: Permission denied also , i cannot find the find in either the current working directory nor in the dir='directory'.so i cant check the permission by using ls -l prefix_u92XQJ_suffix Please help me understand this issue and eventually fix it. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Working with environment variables.
Hello folks, i am working with Python-2.5.2, fedora 9 sulphur I wanna change the value of environment variable , so if i open bash and type envvariable=value;export variable then this sets the envvariable equal to the value.Now i am writing a python script to set the value of this environment variable. import optparse import os def new_callback(option, opt_str, value, parser): os.putenv(envvariable,value) if __name__ == '__main__': p = optparse.OptionParser() p.add_option('-H',action=callback,callback=new_callback,type =string) options, remainder = p.parse_args() when i run the script python prog.h -H value now this dosen't change the value of the variable which was set earlier .Please help me in fixing this issue. Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
I/O error 13 Permission denied -Cannot access file as it is used by another process.
Hello folks, I am creating a python script[windows vista and python2.5] which accesses another program(prog2).I my python script i am creating a temporary file and i write the output of prog2 in this temporary file. temp = tempfile.NamedTemporaryFile(suffix='_suffix',prefix='prefix_',dir='C:\\Python25') - #this how create the temporary file ( i am not closing the temporary file).This works fine x= os.path.split(tn) y=x[1] Now i search for the file and then try to read this file so that i can perform some calculations. This step causes the problem file=open(find_file,rb) # find_file is the object returned after searching the file error mesage: the process cannot access the file as another process because it is being used by another program.(prog2 in this case) i/o error 13 permission denied Please help me on how can i fix this ? i am using os.system() in my program to communicate with prog2 Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
Creating environment variables.
Hello folks, I am writing a program(prog 1) in python , which requires to know the path of another program(prog 2) in order to execute.I can get my prog1 to work when i hard code the path of the existing program(prog2).But since the path of prog could be anywhere on the file system , thus i cannot hard codes its path.And i am not supposed to take the path of prog2 as an input to prog1.So is there anyway to solve this problem , by the creation of environment variable (whose value is set as the path of prog 2)?Also how do i create environment variable for prog1? Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
Environment variables
Hello folks, How can i create environment variables using python? Aditya -- http://mail.python.org/mailman/listinfo/python-list
Extracting path of a program from a list.
Hello folks, I wanna know how can i extract path of a program whose path i have added to the PATH variable. This is what i have done import os x=os.getenv(PATH) print x %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\;C:\folder1\folder2\prog Now i have to extract the path of my program ie (C:\folder1\folder2\prog) .I mean i can split the string using y=x.split(';') a=y[-1] but i dont wanna do this way ,i wanna search for my program from this list and then return its path Please help me on this. Thanks in advance. Aditya -- http://mail.python.org/mailman/listinfo/python-list
File operations
Hello guys I am trying to search a file say xyz.txt after searching i get the location of the file in search_file (containing abspath) ,eg search_file=c:\\abc\\xyz.txt now how should i open this file i can use file=open(c:\\abc\\xyz.txt,rb) but i have to use search_ file How can this be done? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
os.system()- cannot add parameter
Hello folks, I have a program which is in the form of a client-server. i wanna send the parameters from my python script such that the client passes it to the server.this is what i have done Server is running in vmplayer.This is what i have done b=c:\progs os.system('start c:\\pnew\\xyz\\win32\\xyz' + + b) -- now this runs the xyz.exe but does not accept the parameter, where as if i directly give xyz c:\progs through the client(from cmd.exe) then this works. Please help me solve this problem Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
IDLE issue
I found something interesting while working in idle.I have windows vista and python2.5 if i do import subprocess proc =subprocess.Popen('cmd.exe',stdin=subprocess.PIPE,stdout=subprocess.PIPE) output = proc.communicate('dir\n')[0] print repr(output) This dosen't work in idle while if it put it up in a script and run it as python script.py then it works Its strange? Aditya -- http://mail.python.org/mailman/listinfo/python-list
Find file in a given search path
Hello folks, i am trying to find a particular file in a given search path.I found code for this on internet. Code from os.path import exists, join from os import pathsep from string import split def search_file(filename, search_path): Given a search path, find file file_found = 0 paths = string.split(search_path, pathsep) for path in paths: if exists(join(path, filename)): file_found = 1 break if file_found: return abspath(join(path, filename)) else: return None if __name__ == '___main__': search_path = '/bin' + pathsep + '/usr/bin' # ; on windows, : on unix find_file = search_file('ls',search_path) if find_file: print File found at %s % find_file else: print File not found Whenever i try to run the code ie python findpath.py , nothing happens , i mean command prompt reappears . I am using ubuntu and the file is stored at the location -/home/Desktop/Python-2.5.2/Lib. Can someone explain what's happening? Thanks in advance. Aditya. -- http://mail.python.org/mailman/listinfo/python-list
Newbie question about sending and receiving data to the command prompt.
Hello folks, I am using windows vista and i am trying to send data to the command prompt ,this is what is done. import subprocess proc =subprocess.Popen('cmd.exe',stdin=subprocess.PIPE) proc.communicate('abc') when i run this the command prompt just blinks and disappears , can anyone explain what's going on? Similarly when i am trying to receive data from the command prompt the same thing happens.This is what i have done. proc = subprocess.Popen('cmd.exe',stdout=subprocess.PIPE, ) stdout_value = proc.communicate()[0] print '\tstdout:', repr(stdout_value) -command prompt blinks and disappears.Please explain what's happening. Thanks in advance. Aditya -- http://mail.python.org/mailman/listinfo/python-list
Subprocess module question.
Hello folks, I am using windows vista and i am trying to communicate with various processes. so when i do import subprocess proc=subprocess.Popen('cmd.exe') --This opens the command prompt But when i do proc=subprocess.Popen('netscan.exe') it gives an error Traceback (most recent call last): File pyshell#11, line 1, in module proc =subprocess.Popen('netscan.exe') File C:\Python25\lib\subprocess.py, line 594, in __init__ errread, errwrite) File C:\Python25\lib\subprocess.py, line 816, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified However netscan.exe is present on my system. Some please explain why does this happens? Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
command line tool for process communication
Hello guys, I have a program which is run through command line .I am trying to create another command line tools which controls this program. So for example in my new program when i give newprog -a then it should invoke the existing tool and perform one of its operation.eg existtprog -s How could this be done in python? Optparse can be used to make the new tool but what should be done to control the existing tool from the new tool? Thanks in advance. Aditya -- http://mail.python.org/mailman/listinfo/python-list
Taking command line arguments from another program
Hello folks ,I have a program in which a text file is generated as an output eg C:\prog\ prog -x test.txt Right now whenever i have to read the test file i have to put its name manually in my code. eg f=open(c:\\prog\\test.txt,r) How ever i want to add the name of the test file dynamically to my program ie , if every time i give C:\prog\ prog -x test.txt The filename (test.txt) automatically comes in f=open(c:\\prog\\test.txt,r) C:\prog\ prog -x file1.txt f=open(c:\\prog\\file1,r) in other words i do not want to do hard code the name of the file in my code every time i need to read it. I was reading about the sys module and i guess sys.argv would take the input from the command line whenever i run the python script . Please guide me in the right direction on how to tackle the problem. Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
Command line arguements
Hello folks ,I have a program in which a text file is generated as an output eg C:\prog\ prog -x test.txt Right now whenever i have to read the test file i have to put its name manually in my code. eg f=open(c:\\prog\\test.txt,r) How ever i want to add the name of the test file dynamically to my program ie , if every time i give C:\prog\ prog -x test.txt The filename (test.txt) automatically comes in f=open(c:\\prog\\test.txt,r) C:\prog\ prog -x file1.txt f=open(c:\\prog\\file1,r) in other words i do not want to do hard code the name of the file in my code every time i need to read it. I was reading about the sys module and i guess sys.argv would take the input from the command line whenever i run the python script . Please guide me in the right direction on how to tackle the problem. Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
Histogram and \lambda parameter of the laplacian curve.
Thanks everyone for your earlier help. I have to plot a histogram of values lets say [0.5,0.6,0.8,0.9].I guess the histogram would show an exponential decay ie, the laplacian curve. I need to find the \lambda parameter of this curve . So please tell me if it be done through http://matplotlib.sourceforge.net/and are there any other libraries which can be used. Thanks in advance. Aditya -- http://mail.python.org/mailman/listinfo/python-list
Histogram of floating point values.
Hello folks, I have a list say data=[0.99,0.98,0.98,0.98,0.97,0.93,0.92,0.92,0.83,0.66,0.50,0.50] i am trying to plot histogram of these values i have installed numpy and matplotlib and this is what i am doing* import numpy import pylab from numpy import * from pylab import * input_hist=array(data) pylab.hist(input_hist,bins=0.1) and this is the error that i am getting *(array([], dtype=int32), array([ 0.5]), a list of 0 Patch objects)* does this mean that i cannot plot a histogram of floating point values ? or is there a way around Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
Reading a file
I have a text file whose contents are like this:- jd|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc I am trying to read the file like this:- x = open(c:\\a.txt,r) x.read() the result that i get is ike this:- 'jd|fj|dnv|jd|0.33|c:windowswin32\nshcbsbs|nscsjsj|0.93|hsbcjsnc\n' My doubt is how can i read the file as it is? ie my output should be d|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Reading a file
Thanks a lot guys , i got it now. Aditya -- http://mail.python.org/mailman/listinfo/python-list
file operations.
Guys thanks for your previous help .I have a doubt again My text file is :- 0\9\10\11|0.50|c:\windows\apppatch/AcLayers.dll 0\9\10\11|0.50|c:\windows\apppatch/AcRedir.dll 0\9\10|0.66|c:\windows\apppatch/AcSpecfc.dll 0\9|0.83|c:\windows\apppatch/iebrshim.dll 0|0.92|c:\windows\apppatch/pcamain.sdb 0|0.92|c:\windows\apppatch/sysmain.sdb 0|0.93|c:\windows\apppatch/AcXtrnal.dll 0|0.97|c:\windows\apppatch/msimain.sdb 0|0.98|c:\windows\apppatch/AcRes.dll 0|0.98|c:\windows\apppatch/drvmain.sdb 0|0.98|c:\windows\apppatch/en-US/AcRes.dll.mui 0|0.99|c:\windows\apppatch/apihex86.dll 0|1.00|c:\windows\apppatch/AcGenral.dll now this is what happens x=open(c:\\test2.txt,rb) x.readline() '\n' ---? i am not able to understand why is new line character returned here l =x.readline() print l Also , because of this i am not able to extract the floating point values ie 0.50,0.50,0.66 respectively cause when i use the proposed solution given earlier data=[] for line in x: line=line.split(|) data.append(float(line[-2])) -- i am trying to get the floating point values from the back i receive this error message Traceback (most recent call last): File pyshell#71, line 3, in module d.append(float(line[-2])) IndexError: list index out of range Whereas the solution works well with the dummy text file which i have created which is a.txt jd|fj|dnv|jd|0.33|c:\\windows\\win32 shcbsbs|nscsjsj|0.93|hsbcjsnc x=open(a.txt,r) data=[] for line in x: line=line.split(|) data.append(float(line[-2])) print data 0.332,0.936 Please help me fix this problem Thanks in advance Aditya -- http://mail.python.org/mailman/listinfo/python-list
File operations.
Guys i just understood the problem.Thanks for all your help Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re:Taking the floating point distances and plotting histogram
Hello folks:- I have a program whose output is stored in a text file , say test.txt eg. 0\9\10\11|0.50|c:\windows\apppatch/AcLayers.dll 0\9\10\11|0.50|c:\windows\apppatch/AcRedir.dll 0\9\10|0.66|c:\windows\apppatch/AcSpecfc.dll 0\9|0.83|c:\windows\apppatch/iebrshim.dll After reading this text file i need to extract the float point values from each line ie , 0.50,0.50,0.66.0.83 respectively in this case, till the end of the file is reached and then i need to plot a histogram based on these values . Please provide any hints on how to do this. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list