Search Results

Search found 19539 results on 782 pages for 'pretty print'.

Page 91/782 | < Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >

  • update a column in input file by taking value from Database in perl.

    - by Rahul Singh
    input file: 1,a,USA,, 2,b,UK,, 3,c,USA,, i want to update the 4th column in the input file from taking values from one of the table. my code looks like this: my $customer_dbh = DBI-connect("DBI:Oracle:$INST", $USER, $PASS ) or die "Couldn't connect to datbase $INST"; my $cust_smh; print "connected \n "; open FILE , "+$input_file" or die "can't open the input file"; print "echo \n"; while(my $line=) { my @line_a=split(/\,/,$line); my $customer_id=$line_a[3]; print "$customer_id\n"; $cust_smh = $customer_dbh-prepare("SELECT phone_no from book where number = $line_a[0]"); $cust_smh-execute() or die "Couldn't execute stmt, error : $DBI::errstr"; my $number = $cust_smh-fetchrow_array(); $line_a[3]=$number; }

    Read the article

  • How to handle printing of HTML pages?

    - by Jaran
    In my portfolio site I have listed my projects under separate tabs (tab menu). This works well except for printing which requires the user to click on a tab, print, click on the next tab and print the same page again to get everything. Being a portfolio I'd assume that visitors want to print all of the content. Is there a general way to create a different style when printing a web page? Or should I just add a printer icon on my page which redirects the user to a different page where all the data is in a big chunk and then prompt the user's browser to start printing?

    Read the article

  • reinitialize an object with self.__init__(...)

    - by Kara Jevo
    Could anybody explain whether it is safe to reinitialize an object by calling "self.init(". as shown in the following simplified example? The reason i'm asking is that i couldn't find this method neither in several python books nor in internet. There are some who suggest to list all attributes and set them to initial value one by one. Basically i want to set my object to initial state after it has finished some tasks. class Book(object): def __init__(self,name,author): self.name = name self.author = author self.copies = 5 def reset(self): self.__init__(self.name,self.author) def incrementCopy(self): self.copies += 1 Kite = Book('kite runner','khaled hosseini') print 'initial number of copies:', Kite.copies Kite.incrementCopy() Kite.incrementCopy() Kite.incrementCopy() print '3 copies are added:', Kite.copies Kite.reset() print 'number of copies are reinitialized', Kite.copies initial number of copies: 5 3 copies are added: 8 number of copies are reinitialized 5

    Read the article

  • socket.error: [Errno 10054]

    - by C0d3r
    import socket, sys if len(sys.argv) !=3 : print "Usage: ./supabot.py <host> <port>" sys.exit(1) irc = sys.argv[1] port = int(sys.argv[2]) sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((irc, port)) sck.send('NICK supaBOT\r\n') sck.send('USER supaBOT supaBOT supaBOT :supaBOT Script\r\n') sck.send('JOIN #darkunderground' + '\r\n') data = '' while True: data = sck.recv(1024) if data.find('PING') != -1: sck.send('PONG ' + data.split() [1] + '\r\n') print data elif data.find('!info') != -1: sck.send('PRIVMSG #darkunderground supaBOT v1.0 by sourD' + '\r\n') print sck.recv(1024) when I run this code I get this error.. socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host it says that the error is in line 16, in data = sck.recv(1024)

    Read the article

  • what is Perl equivalent of php $_POST and how to use it?

    - by dexter
    i have two perl files that is .pl files one is action.pl and another one is test.pl action.pl has a html form as: print $cgi->header, <<html; <form action="test.pl" method="post"> html while (my @row = $sth->fetchrow) { print $cgi->header, <<html; ID:<input name="pid" value="@row[0]" readonly="true"/><br/> Name: <input name="pname" value="@row[1]"/><br/> Description : <input name="pdescription" value="@row[2]"/><br/> Unit Price :<input name="punitprice" value="@row[3]"/><br/> html } print $cgi->header, <<html <input type="submit" value="update Row"> </form> html now, my question is what should i wright in test.pl so as to read what form is sending it?? in Other words what is Perl equivalent of PHP: $_POST['pid'] so that in test'pl we can read the data sent via form

    Read the article

  • RUNNING PHP IN NETBEANS

    - by user216112
    i have netbeans 6.8 with all bundle faetures. now i m running my php file Binary Search h1 {color: blue} Computer guess number by using binary search Input your hidden number: (1-99) Here; } else { if ($max_num==-1 && $min_num==-1) { $max_num = 100; $min_num = 0; $result_num = $hid_num; } else { if ($comparision == "bigger") { $min_num = $guess_num; } else if ($comparision == "smaller") { $max_num = $guess_num; } } $guess_num = ($max_num + $min_num)/2; setType($guess_num,"integer"); print "Computer guess $guess_num "; if ($guess_num == $result_num) { $flag_num = -1; } if ($flag_num == -1) { print Congratulation, Computer win " Here; } else { print Your intruction: Bigger Smaller Here; } } ? but the erreor coming in the "HTTP 404 NOT FOUND" I THINK SERVER HAS BEEN NOT BEEN SET.SO WHAT SHOULD I DO TO RUN IT

    Read the article

  • how to show the right word in my code, my code is : os.urandom(64)

    - by zjm1126
    My code is: print os.urandom(64) which outputs: > "D:\Python25\pythonw.exe" "D:\zjm_code\a.py" \xd0\xc8=<\xdbD' \xdf\xf0\xb3>\xfc\xf2\x99\x93 =S\xb2\xcd'\xdbD\x8d\xd0\\xbc{&YkD[\xdd\x8b\xbd\x82\x9e\xad\xd5\x90\x90\xdcD9\xbf9.\xeb\x9b>\xef#n\x84 which isn't readable, so I tried this: print os.urandom(64).decode("utf-8") but then I get: > "D:\Python25\pythonw.exe" "D:\zjm_code\a.py" Traceback (most recent call last): File "D:\zjm_code\a.py", line 17, in <module> print os.urandom(64).decode("utf-8") File "D:\Python25\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-3: invalid data What should I do to get human-readable output?

    Read the article

  • Communicate multiple times with a process without breaking the pipe?

    - by Manux
    Hello, it's not the first time I'm having this problem and its really bugging me. Whenever I open a pipe using the Python subprocess module, I can only communicate with it once, as the documentation specifies: Read data from stdout and stderr, until end-of-file is reached proc = sub.Popen("psql -h darwin -d main_db".split(),stdin=sub.PIPE,stdout=sub.PIPE) print proc.communicate("select a,b,result from experiment_1412;\n")[0] print proc.communicate("select theta,zeta,result from experiment_2099\n")[0] The problem here is that the second time, Python isn't happy. Indeed, he decided to close the file after the first communicate: Traceback (most recent call last): File "a.py", line 30, in <module> print proc.communicate("select theta,zeta,result from experiment_2099\n")[0] File "/usr/lib64/python2.5/subprocess.py", line 667, in communicate return self._communicate(input) File "/usr/lib64/python2.5/subprocess.py", line 1124, in _communicate self.stdin.flush() ValueError: I/O operation on closed file So... multiple communications aren't allowed? I hope not ;) Please enlighten me.

    Read the article

  • Can't get Angular Dart Router to work

    - by JesterXL
    I've tried this syntax in AngularDart 0.11.0: Angular Dart passing data from route service into a controller module.value(RouteInitializerFn, configureRoutes); void configureRoutes(Router router, RouteViewFactory views) { print("configureRoutes"); views.configure({ 'login': ngRoute( path: '/login', view: 'login/login.tpl.html'), 'today': ngRoute( path: '/today', view: '/today/today.tpl.html') }); However, my routing function never seems to get called. I've used both a print statement and breakpoint to no avail. When I attempt to call it like so: WorkoutLoggerApplication(this.rootScope, this.router) { print("WorkoutLoggerApplication::constructor"); new Future.delayed(new Duration(seconds: 2), () { router.go("login", {}); }); } I get: Bad state: Invalid route name: login I've tried 0.10.0, but no dice. I've also tried 3 varieties of the new bind function format, both also don't seem to ever fire the routing function.

    Read the article

  • Please quickly help with this problem I got 52 minutes left.

    - by Hamish Grubijan
    Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". Woman said use any common language. Please make it short and test it. My screen is small. Thanks. P.S. I have test anxiety particularly after talking to people in suits. I also stayed up all night studying Java codes.

    Read the article

  • best way to prgram php and mysql query

    - by air
    most of times in our pages we need to print only 1 field value of table in loop. for example <?php for($i=1;$i<=mysql_num_rows($result);$i++) { echo $row['name']; $sql1="select industry from table_industry where profid='".$row['prof']."'"; $result1=mysql_query($sql1); $row1=mysql_fetch_array($result1); echo $row1['industry']; ?> } ?> above is one PHP code just for example where we think that $row['prof'] carry value of profession ID and we print profession of each person. for example we have 5000+ record in table and above loop will execute for 5000+ times what will be the best way to print value of industry field from table table_industry Same code which i write above ? any other php code suggestion for faster execution and less use of resources? Thanks

    Read the article

  • Format attribute of <bean:write> tag in Struts

    - by Sushant Taneja
    Hello All, I am developing a web application using Struts 1.2.7 I want to print a list of integers using the tag. I searched and found that the format attribute is used to print the desired result but was unsuccessful. What should I pass as the value in format to print 3 digit integers/floating point numbers. The code sample is as follows: <logic:iterate name="intList" id="integer" > <bean:write name="integer" /> <logic:iterate /> Here intList is a List of int(s) passed as a request attribute to the jsp page under consideration.

    Read the article

  • how to import Java class with Python using Eclipse?

    - by JChao
    Hi, I'm trying to write Jython where the Python file imports classes from Java I'm using Eclipse with PyDev. My Python code looks like: from eclipsejavatest import eclipseJavaTest from eclipsejavatest import JavaClass class eclipsePyPrint(eclipseJavaTest): def eclipsepyMain(self): print "python main method" eclipseJavaTest.printerCount(4) print eclipseJavaTest.gotoPython() eclipseJavaTest.printerSentence() samplepyClass = JavaClass("Jython plain") samplepyClass.setName("jython fancy") print samplepyClass.getName() but I'm getting the error ImportError: No module named eclipsejavatest The Python project references the Java project. I've tried exporting the Java project and adding the .jar to the Jython Class Path for the Python project. I'm not sure what to do to get this to work.

    Read the article

  • PHP Export Date range

    - by menormedia
    I have a working database export to xls but I need it to export a particular date range based on the 'closed' date. (See code below). For example, I'd like it to export all 'closed' dates for last month and/or this month (Range: Sept 1, 2012 to Sept 30, 2012 or Oct 1, 2012 to Oct 31, 2012) <?PHP //EDIT YOUR MySQL Connection Info: $DB_Server = "localhost"; //your MySQL Server $DB_Username = "root"; //your MySQL User Name $DB_Password = ""; //your MySQL Password $DB_DBName = "ost_helpdesk"; //your MySQL Database Name $DB_TBLName = "ost_ticket"; //your MySQL Table Name //$DB_TBLName, $DB_DBName, may also be commented out & passed to the browser //as parameters in a query string, so that this code may be easily reused for //any MySQL table or any MySQL database on your server //DEFINE SQL QUERY: //edit this to suit your needs $sql = "Select ticketID, name, company, subject, closed from $DB_TBLName ORDER BY closed DESC"; //Optional: print out title to top of Excel or Word file with Timestamp //for when file was generated: //set $Use_Titel = 1 to generate title, 0 not to use title $Use_Title = 1; //define date for title: EDIT this to create the time-format you need $now_date = DATE('m-d-Y'); //define title for .doc or .xls file: EDIT this if you want $title = "MDT Database Dump For Table $DB_TBLName from Database $DB_DBName on $now_date"; /* Leave the connection info below as it is: just edit the above. (Editing of code past this point recommended only for advanced users.) */ //create MySQL connection $Connect = @MYSQL_CONNECT($DB_Server, $DB_Username, $DB_Password) or DIE("Couldn't connect to MySQL:<br>" . MYSQL_ERROR() . "<br>" . MYSQL_ERRNO()); //select database $Db = @MYSQL_SELECT_DB($DB_DBName, $Connect) or DIE("Couldn't select database:<br>" . MYSQL_ERROR(). "<br>" . MYSQL_ERRNO()); //execute query $result = @MYSQL_QUERY($sql,$Connect) or DIE("Couldn't execute query:<br>" . MYSQL_ERROR(). "<br>" . MYSQL_ERRNO()); //if this parameter is included ($w=1), file returned will be in word format ('.doc') //if parameter is not included, file returned will be in excel format ('.xls') IF (ISSET($w) && ($w==1)) { $file_type = "msword"; $file_ending = "doc"; }ELSE { $file_type = "vnd.ms-excel"; $file_ending = "xls"; } //header info for browser: determines file type ('.doc' or '.xls') HEADER("Content-Type: application/$file_type"); HEADER("Content-Disposition: attachment; filename=MDT_DB_$now_date.$file_ending"); HEADER("Pragma: no-cache"); HEADER("Expires: 0"); /* Start of Formatting for Word or Excel */ IF (ISSET($w) && ($w==1)) //check for $w again { /* FORMATTING FOR WORD DOCUMENTS ('.doc') */ //create title with timestamp: IF ($Use_Title == 1) { ECHO("$title\n\n"); } //define separator (defines columns in excel & tabs in word) $sep = "\n"; //new line character WHILE($row = MYSQL_FETCH_ROW($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; FOR($j=0; $j<mysql_num_fields($result);$j++) { //define field names $field_name = MYSQL_FIELD_NAME($result,$j); //will show name of fields $schema_insert .= "$field_name:\t"; IF(!ISSET($row[$j])) { $schema_insert .= "NULL".$sep; } ELSEIF ($row[$j] != "") { $schema_insert .= "$row[$j]".$sep; } ELSE { $schema_insert .= "".$sep; } } $schema_insert = STR_REPLACE($sep."$", "", $schema_insert); $schema_insert .= "\t"; PRINT(TRIM($schema_insert)); //end of each mysql row //creates line to separate data from each MySQL table row PRINT "\n----------------------------------------------------\n"; } }ELSE{ /* FORMATTING FOR EXCEL DOCUMENTS ('.xls') */ //create title with timestamp: IF ($Use_Title == 1) { ECHO("$title\n"); } //define separator (defines columns in excel & tabs in word) $sep = "\t"; //tabbed character //start of printing column names as names of MySQL fields FOR ($i = 0; $i < MYSQL_NUM_FIELDS($result); $i++) { ECHO MYSQL_FIELD_NAME($result,$i) . "\t"; } PRINT("\n"); //end of printing column names //start while loop to get data WHILE($row = MYSQL_FETCH_ROW($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; FOR($j=0; $j<mysql_num_fields($result);$j++) { IF(!ISSET($row[$j])) $schema_insert .= "NULL".$sep; ELSEIF ($row[$j] != "") $schema_insert .= "$row[$j]".$sep; ELSE $schema_insert .= "".$sep; } $schema_insert = STR_REPLACE($sep."$", "", $schema_insert); //this corrects output in excel when table fields contain \n or \r //these two characters are now replaced with a space $schema_insert = PREG_REPLACE("/\r\n|\n\r|\n|\r/", " ", $schema_insert); $schema_insert .= "\t"; PRINT(TRIM($schema_insert)); PRINT "\n"; } } ?>

    Read the article

  • Crystal Reports - Facilitating front/back printing

    - by hamlin11
    I have a crystal report that is designed to spit out a bunch of reports. Each report is 2 to 7 pages in length. We would like to print on the front and back of pages. However, if we did this now... approximately half of the following reports would print on the back of the last past of the preceding report. Is there a good method for detecting whether an extra page break should be inserted, and if so, actually inserting it, so that when we print the 150 pages front/back that now one piece of paper actually holds data from separate reports? Thanks

    Read the article

  • In python, is there anyway to have a variable be a different random number everytime?

    - by woah113
    Basically I have this: import random variable1 = random.randint(13, 19) And basically what that does is assign variable1 a random number between 13 and 19. Great. But, what I want it to do is assign a different random number between 13 and 19 to that variable every time it is called. Is there anyway I can do this? If I'm not being clear enough here's an example: import random variable1 = random.randint(13, 19) print(variable1) print(variable1) print(variable1) And the output I want would look something like this: ./script.py 15 19 13 So yeah, anyway I could do this in python? (More specifically python3. but the answer would probably be similar to a python2 answer)

    Read the article

  • Best way to test instance methods without running __init__

    - by KenFar
    I've got a simple class that gets most of its arguments via init, which also runs a variety of private methods that do most of the work. Output is available either through access to object variables or public methods. Here's the problem - I'd like my unittest framework to directly call the private methods called by init with different data - without going through init. What's the best way to do this? So far, I've been refactoring these classes so that init does less and data is passed in separately. This makes testing easy, but I think the usability of the class suffers a little. EDIT: Example solution based on Ignacio's answer: import types class C(object): def __init__(self, number): new_number = self._foo(number) self._bar(new_number) def _foo(self, number): return number * 2 def _bar(self, number): print number * 10 #--- normal execution - should print 160: ------- MyC = C(8) #--- testing execution - should print 80 -------- MyC = object.__new__(C) MyC._bar(8)

    Read the article

  • Weird callback execution order in Twisted?

    - by SlashV
    Consider the following code: from twisted.internet.defer import Deferred d1 = Deferred() d2 = Deferred() def f1(result): print 'f1', def f2(result): print 'f2', def f3(result): print 'f3', def fd(result): return d2 d1.addCallback(f1) d1.addCallback(fd) d1.addCallback(f3) #/BLOCK==== d2.addCallback(f2) d1.callback(None) #=======BLOCK/ d2.callback(None) This outputs what I would expect: f1 f2 f3 However when I swap the order of the statements in BLOCK to #/BLOCK==== d1.callback(None) d2.addCallback(f2) #=======BLOCK/ i.e. Fire d1 before adding the callback to d2, I get: f1 f3 f2 I don't see why the time of firing of the deferreds should influence the callback execution order. Is this an issue with Twisted or does this make sense in some way?

    Read the article

  • EnumJobs not returning Copies & Total Pages

    - by Hein du Plessis
    I'm using Windows API's EnumJobs to find the PageCount and Copies of a print job, but I found that these fields are almost always zero when called on a print server. Although it could be my timing is out, because the number of pages increment as the job prints and once it's done the print job cannot be accessed. So there is about half a nanosecond when the values in EnumJobs is correct before it dissapears. I've been scouring the web but can't find any help on this, just other people with similar problems. Anybody with experience with EnumJobs or can suggest other means of determining the total number of pages printed?

    Read the article

  • Python - List and Loop in one def

    - by Dunwitch
    I'm trying to get the def wfsc_pod1 and wfsc_ip into the same def. I'm not quite sure how to approach the problem. I want wfsc_pod1 to display all the information for name, subnet and gateway. Then wfsc_ip shows the ip addresses below it. I also get a None value when I run it as it. Not sure why. Anything more pythonic is more appreciated. class OutageAddress: subnet = ["255.255.255.0", "255.255.255.1"] # Gateway order is matched with names gateway = ["192.168.1.1", "192.168.1.2", "192.168.1.3", "192.168.1.4", "192.168.1.5", "192.168.1.6", "192.168.1.7", "192.168.1.8", "192.168.1.9"] name = ["LOC1", "LOC2", "LOC3", "LOC4", "LOC5", "LOC6", "LOC7", "LOC8", "LOC9"] def wfsc_pod1(self): wfsc_1 = "%s\t %s\t %s\t" % (network.name[0],network.subnet[0],network.gateway[0]) return wfsc_1 def wfsc_ip(self): for ip in range(100,110): ip = "192.168.1."+str(ip) print ip network = OutageAddress() print network.wfsc_pod1() print network.wfsc_ip()

    Read the article

  • Assign value to list

    - by Kenneth B
    Hello First and foremost. I'm totally new to "programming" in Excel. I'm trying to make a price calculator, that calculates the price when I use my printer. I have made some lists so it's easy to perform the calculations. Single or duplex: Singlex/Duplex Format: SRA3 / A4 / SRA3 High Gloss The idea is that if I type in an amount of 100 prints, choose SRA3 format on the list, and choose Duplex on the other list. the calculation would look like this: This is how it's calculated: Paper + (print x sides) = Price of the print job Print prices Per page (singlex or duplex): 0,6 Paper format and price: A4 reg. paper: 0,2 SRA3 High Gloss: 1,25 SRA3 reg. paper: 1 Does anyone know about this???

    Read the article

  • question about c++ template functions taking any type as long that type meets at least one of the re

    - by smerlin
    Since i cant explain this very well, i will start with a small example right away: template <class T> void Print(const T& t){t.print1();} template <class T> void Print(const T& t){t.print2();} This does not compile: error C2995: 'void Print(const T &)' : function template has already been defined So, how can i create a template function which takes any type T as long as that type has a print1 memberfunction OR a print2 memberfunction (no polymorphism) ?

    Read the article

  • python processs complete list files matched

    - by thomytheyon
    Hi All, I'm trying to get a simple code working, unfortunatly im a python beginner. My script should return a list of files that doesn't match a pattern, more information here : http://stackoverflow.com/questions/2910106/python-grep-reverse-matching/2910288#2910288 My code is running but doesn't process the complete list of files found as it should : import sys,os filefilter = ['.xml','java','.jsp','lass'] path= "/home/patate/code/project" s = "helloworld" for path, subdirs, files in os.walk(path): for name in files: if name[-4:] in filefilter : f = str(os.path.join(path, name)) with open(f) as fp: if s in fp.read(): print "%s has the string" % f else: print "%s doesn't have the string" % f This code return : /home/patate/code/project/blabla/blabla/build.xml doesn't have the string None If i change f = str(os.path.join(path, name)) for print str(os.path.join(path, name)) I can see the whole list being printed. How can i process the whole list as i which to ? :( Thanks again.

    Read the article

  • += Overloading in C++ problem.

    - by user69514
    I am trying to overload the += operator for my rational number class, but I don't believe that it's working because I always end up with the same result: RationalNumber RationalNumber::operator+=(const RationalNumber &rhs){ int den = denominator * rhs.denominator; int a = numerator * rhs.denominator; int b = rhs.numerator * denominator; int num = a+b; RationalNumber ratNum(num, den); return ratNum; } Inside main //create two rational numbers RationalNumber a(1, 3); a.print(); RationalNumber b(6, 7); b.print(); //test += operator a+=(b); a.print(); After calling a+=(b), a is still 1/3, it should be 25/21. Any ideas what I am doing wrong?

    Read the article

  • interuption while running php file

    - by user216112
    this is my code in php bt its not working problerly as required..the output is not according to this.. i m trying to run this in wamp server. plz help /* Binary Search h1 {color: blue} Computer guess number by using binary search Input your hidden number: (1-99) Here; } else { if ($max_num==-1 && $min_num==-1) { $max_num = 100; $min_num = 0; $result_num = $hid_num; } else { if ($comparision == "bigger") { $min_num = $guess_num; } else if ($comparision == "smaller") { $max_num = $guess_num; } } $guess_num = ($max_num + $min_num)/2; setType($guess_num,"integer"); print "Computer guess $guess_num "; if ($guess_num == $result_num) { $flag_num = -1; } if ($flag_num == -1) { print Congratulation, Computer win " Here; } else { print Your intruction: Bigger Smaller Here; } } ? */

    Read the article

< Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >