Search Results

Search found 3176 results on 128 pages for 'parsing'.

Page 6/128 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Parsing files "/etc/default" using java

    - by rmarimon
    I'm trying to parse the configuration files usually found in /etc/default using java and regular expressions. So far this is the code I have iterating over every line on each file: // remove comments from the line int hash = line.indexOf("#"); if (hash >= 0) { line = line.substring(0, hash); } // create the patterns Pattern doubleQuotePattern = Pattern.compile("\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*=\\s*\"(.*)\"\\s*"); Pattern singleQuotePattern = Pattern.compile("\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*=\\s*\\'(.*)\\'\\s*"); Pattern noQuotePattern = Pattern.compile("\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*=(.*)"); // try to match each of the patterns to the line Matcher matcher = doubleQuotePattern.matcher(line); if (matcher.matches()) { System.out.println(matcher.group(1) + " == " + matcher.group(2)); } else { matcher = singleQuotePattern.matcher(line); if (matcher.matches()) { System.out.println(matcher.group(1) + " == " + matcher.group(2)); } else { matcher = noQuotePattern.matcher(line); if (matcher.matches()) { System.out.println(matcher.group(1) + " == " + matcher.group(2)); } } } This works as I expect but I'm pretty sure that I can make this way smaller by using better regular expression but I haven't had any luck. Anyone know of a better way to read these types of files?

    Read the article

  • Parsing/Tokenizing a String Containing a SQL Command

    - by Alan Storm
    Are there any open source libraries (any language, python/PHP preferred) that will tokenize/parse an ANSI SQL string into its various components? That is, if I had the following string SELECT a.foo, b.baz, a.bar FROM TABLE_A a LEFT JOIN TABLE_B b ON a.id = b.id WHERE baz = 'snafu'; I'd get back a data structure/object something like //fake PHPish $results['select-columns'] = Array[a.foo,b.baz,a.bar]; $results['tables'] = Array[TABLE_A,TABLE_B]; $results['table-aliases'] = Array[a=TABLE_A, b=TABLE_B]; //etc... Restated, I'm looking for the code in a database package that teases the SQL command apart so that the engine knows what to do with it. Searching the internet turns up a lot of results on how to parse a string WITH SQL. That's not what I want. I realize I could glop through an open source database's code to find what I want, but I was hoping for something a little more ready made, (although if you know where in the MySQL, PostgreSQL, SQLite source to look, feel free to pass it along) Thanks!

    Read the article

  • Equation parsing in Python

    - by MikeCroucher
    How can I (easily) take a string such as 'sin(x)*x^2' which might be entered by a user at runtime and produce a python function that could be evaluated for any value of x? Does anyone know of any libraries or modules that takes care of this sort of thing?

    Read the article

  • Problem Parsing JSON Result with jQuery

    - by senfo
    I am attempting to parse JSON using jQuery and I'm running into issues. In the code below, I'm using a static file, but I've also tested using an actual URL. For some reason, the data keeps coming back as null: <!DOCTYPE html> <html> <head> <title>JSON Test</title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $.getJSON('results.json', function(data) { alert(data); // Result is always null }); </script> </head> <body> </body> </html> The JSON results look like the following: {"title":"HEALTHPOINT TYEE CAMPUS","link":"http://www.healthpointchc.org","id":"tag:datawarehouse.hrsa.gov,2010-04-29:/8357","org":"HEALTHPOINT TYEE CAMPUS","address":{"street-address":"4424 S. 188TH St.","locality":"Seatac","region":"Washington","postal-code":"98188-5028"},"tel":"206-444-7746","category":"Service Delivery Site","location":"47.4344818181818 -122.277672727273","update":"2010-04-28T00:00:00-05:00"} If I replace my URL with the Flickr API URL (http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?), I get back a valid JSON result that I am able to make use of. I have successfully validated my JSON at JSONLint, so I've run out of ideas as to what I might be doing wrong. Any thoughts?

    Read the article

  • Need help parsing file/writing script

    - by Bradley Herman
    Hey all, I have been doing nothing but web development over the last few years and haven't written any Java or C++ in what feels like forever. I don't necessarily need to use these languages, so I'm entirely open to suggestion. I was given an email list by a client to import into their mailchimp account yesterday and unfortunately, Mailchimp couldn't read the file. It's a text file, but I don't believe it's tab delimited (which would make this much, much easier for me). A small portion of the file (I've changed last names and email addresses) can be viewed here: http://sparktoignite.com/patients.txt If anyone has suggestions on how I can get this into a Mailchimp readable format (csv, tab delimited txt, excel) please let me know. I feel like 3 years ago I would've been able to do this in a matter of minutes, but given that I haven't touched anything other than RoR, PHP, and jQuery for the last few years, I don't know where to start. Thanks!

    Read the article

  • Parsing a XML File and Replacing Chosen Node With Values From Text File

    - by transmogrify
    I wrote a C# Winforms program to take a XML file and load values from a text file into each occurrence of that field which the user specifies on the UI. For whatever reason, the program inserts a carriage return on any nodes which don't contain a value. For example, it will do that to <example></example> whereas it will not misbehave on something like <country>USA</country> What is causing it to do this and how can I prevent it? Here is the code from the part which handles this functionality. XmlDocument LoadXmlDoc = new XmlDocument(); StreamReader sr = File.OpenText(DataLoadTxtBx.Text); string InputFromTxtFile; LoadXmlDoc.Load(XmlPath.Text); XmlNodeList NodeToCreateOrReplace = LoadXmlDoc.GetElementsByTagName(XmlTagNameTxtBx.Text); foreach (XmlNode SelectedNode in NodeToCreateOrReplace) { if ((InputFromTxtFile = sr.ReadLine()) != null) { SelectedNode.InnerText = InputFromTxtFile; } } sr.Close(); LoadXmlDoc.Save(XmlPath.Text);

    Read the article

  • Parsing xml with dom4j or jdom or anyhow

    - by c0mrade
    Hello, I wanna read feed entries and I'm just stuck now. Take this for example : http://stackoverflow.com/feeds/question/2084883 lets say I wanna read all the summary node value inside each entry node in document. How do I do that? I've changed many variations of code this one is closest to what I want to achieve I think : Element entryPoint = document.getRootElement(); Element elem; for(Iterator iter = entryPoint.elements().iterator(); iter.hasNext();){ elem = (Element)iter.next(); System.out.println(elem.getName()); } It goes trough all nodes in xml file and writes their name. Now what I wanted to do next is if(elem.getName() == "entry") to get only the entry nodes, how do I get elements of the entry nodes, and how to get let say summary and its value? tnx

    Read the article

  • DateTime c# parsing

    - by Dani
    I try to parse DateTime.TryParse("30-05-2010"), and it throws an exception because it accepts MMddyyyy, and I need ddMMyyyy format. how can I change TryParse format? thanks, Dani

    Read the article

  • Parsing Indentation-based syntaxes in Haskell's Parsec

    - by pavpanchekha
    I'm trying to parse an indentation-based language (think Python, Haskell itself, Boo, YAML) in Haskell using Parsec. I've seen the IndentParser library, and it looks like it's the perfect match, but what I can't figure out is how to make my TokenParser into an indentation parser. Here's the code I have so far: import qualified Text.ParserCombinators.Parsec.Token as T import qualified Text.ParserCombinators.Parsec.IndentParser.Token as IT lexer = T.makeTokenParser mylangDef ident = IT.identifier lexer This throws the error: parser2.hs:29:28: Couldn't match expected type `IT.TokenParser st' against inferred type `T.GenTokenParser s u m' In the first argument of `IT.identifier', namely `lexer' In the expression: IT.identifier lexer In the definition of `ident': ident = IT.identifier lexer What am I doing wrong? How should I create an IT.TokenParser? Or is IndentParser broken and to be avoided?

    Read the article

  • Objective C - RegexKitLite - Parsing inner contents of a string, ie: start(.*?)end

    - by Stu
    Please consider the following: NSString *myText = @"mary had a little lamb"; NSString *regexString = @"mary(.*?)little"; for)NSString *match in [myText captureComponentsMatchedByRegex:regexString]){ NSLog(@"%@",match); } This will output to the console two things: 1) "mary had a little" 2) "had a" What I want is just the 2nd bit of information "had a". Is there is a way of matching a string and returning just the inner part? I'm fairly new to Objective C, this feels a rather trivial question yet I can't find a less messy way of doing this than incrementing an integer in the for loop and on the second iteration storing the "had a" in an NSString.

    Read the article

  • Parsing a URL - Php Question

    - by Adi Mathur
    I am using the Following code <?php $url = 'http://www.ewwsdf.org/012Q/rhod-05.php?arg=value#anchor'; $parse = parse_url($url); $lnk= "http://".$parse['host'].$parse['path']; echo $lnk; ?> This is giving me the output as http://www.ewwsdf.org/012Q/rhod-05.php How can i modify the code so that i get the output as http://www.ewwsdf.org/012Q/ Just need the Directory name without the file name ( I actually need the link so that i can link up the images which are on the pages, By appending the link behind the image Eg http://www.ewwsdf.org/012Q/hi.jpg )

    Read the article

  • Parsing email with Python

    - by Manuel Ceron
    I'm writing a Python script to process emails returned from Procmail. As suggested in this question, I'm using the following Procmail config: :0: |$HOME/process_mail.py My process_mail.py script is receiving an email via stdin like this: From hostname Tue Jun 15 21:43:30 2010 Received: (qmail 8580 invoked from network); 15 Jun 2010 21:43:22 -0400 Received: from mail-fx0-f44.google.com (209.85.161.44) by ip-73-187-35-131.ip.secureserver.net with SMTP; 15 Jun 2010 21:43:22 -0400 Received: by fxm19 with SMTP id 19so170709fxm.3 for <[email protected]>; Tue, 15 Jun 2010 18:47:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.84.1 with SMTP id m1mr2774225mul.26.1276652853684; Tue, 15 Jun 2010 18:47:33 -0700 (PDT) Received: by 10.123.143.4 with HTTP; Tue, 15 Jun 2010 18:47:33 -0700 (PDT) Date: Tue, 15 Jun 2010 20:47:33 -0500 Message-ID: <[email protected]> Subject: TEST 12 From: Full Name <[email protected]> To: [email protected] Content-Type: text/plain; charset=ISO-8859-1 ONE TWO THREE I'm trying to parse the message in this way: >>> import email >>> msg = email.message_from_string(full_message) I want to get message fields like 'From', 'To' and 'Subject'. However, the message object does not contain any of these fields. What am I doing wrong?

    Read the article

  • Tool for parsing smtp logs that finds bounces

    - by Željko Filipin
    Our web application sends e-mails. We have lots of users, and we get lots of bounces. For example, user changes company and his company e-mail is no longer valid. To find bounces, I parse smtp log file with log parser. Some bounces are great, like 550+#[email protected]. There is [email protected] in bounce. But some do not have e-mail in error message, like 550+No+such+recipient. I have created simple ruby script that parses logs (uses log parser) to find which mail caused something like 550+No+such+recipient. I am just surprised that I could not find a tool that does it. I have found tools like zabbix and splunk for log analysis, but they look like overkill for such simple task. Anybody knows a tool that would parse smtp logs, find bounces and e-mails that cause them? Edit: smtp server is microsoft smtp server.

    Read the article

  • Question on dynamic URL parsing

    - by jerebear
    I see many, many sites that have URLs for individual pages such as http://www.mysite.com/articles/this-is-article-1 http://www.mysite.com/galleries/575 And they don't redirect, they don't run slowly... I know how to parse URL's, that's easy enough. But in my mind, that seems slow and cumbersome on a dynamic site. As well, if the pages are all staticly built (hende the custom URL) then that means all components of the page are static as well... (which would be bad) I'd love to hear some ideas about how this is typically accomplished.

    Read the article

  • Shell script argument parsing

    - by Peter Coulton
    There are a number of questions about this sort of thing but lets imagine we are targeting a generic Linux system with both getopt and getopts installed (not that we'll use either, but they seem popular) How do I parse both long (--example | --example simple-option) and short argruments (-e | -esimple-example | -e simple-example)

    Read the article

  • Parsing String to Time and insert in mysqldatabase

    - by kawtousse
    Goal: Parse a string from an input type text into TIME type to be inserted in MYSQL Database. String start= request.getParameter("startp"); System.out.println("start:" +start); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); long ms=0; try { ms = sdf.parse(start).getTime(); System.out.println(" the value of ms is:" +ms); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Time ts = new Time(ms); System.out.println("the value of ts is:" +ts); start:14:12 (value witch i entered actually in the form at the start field named startp) the value of ts is :01:00:00 java.text.ParseException: Unparseable date: "14:12" at java.text.DateFormat.parse(Unknown Source) ms not displayed I ensure that database type of the following parameter is TIME. Thanks.

    Read the article

  • Regarding XML Parsing

    - by Anjan
    I am using IXMLDOMNodeListPtr , IXMLDOMNodePtr , IXMLDOMElementPtr and IXMLDOMDocPtr. I am having little confusion over here i.e. Should i have to call Release() on these pointers before they go out of scope. Thanks.

    Read the article

  • vb.net and html parsing

    - by tridat
    Currently I'm using the IHTMLDocument2 and IHTMLElementCollection to parse HTML, is there some way to parse it using some sort of xpath/selectors, something like elements = find_html_elements("a .link[rel=100]") ?

    Read the article

  • parsing a string of ascii text into separate variables

    - by jml
    Hi there, I have a piece of text that gets handed to me like: here is line one\n\nhere is line two\n\nhere is line three What I would like to do is break this string up into three separate variables. I'm not quite sure how one would go about accomplishing this in python. Thanks for any help, jml

    Read the article

  • Data mining - parsing a log file in Java

    - by nuvio
    Hello I am carrying on a Java project for the university, where I should analyse poker hands. I found some poker hands in a txt log file. They would typically look like this: PokerStars Zoom Hand #86981279921: Hold'em No Limit ($0.10/$0.25 USD) - 2012/09/30 23:49:51 ET Table 'Whirlpool Zoom 40-100 bb' 9-max Seat #1 is the button Seat 1: lgwong ($30.99 in chips) Seat 2: hastyboots ($28.61 in chips) Seat 3: seula i ($25.31 in chips) Seat 4: fr_kevin01 ($31.81 in chips) Seat 5: limey05 ($27.45 in chips) Seat 6: sanlu ($24.65 in chips) Seat 7: Masterfrank ($25.35 in chips) Seat 8: Refu$e2Lose ($33.23 in chips) Seat 9: 1pepepe0114 ($37.62 in chips) hastyboots: posts small blind $0.10 seula i: posts big blind $0.25 *** HOLE CARDS *** fr_kevin01: folds limey05: folds sanlu: folds Masterfrank: folds Refu$e2Lose: folds 1pepepe0114: folds lgwong: folds hastyboots: folds Uncalled bet ($0.15) returned to seula i seula i collected $0.20 from pot seula i: doesn't show hand *** SUMMARY *** Total pot $0.20 | Rake $0 Seat 1: lgwong (button) folded before Flop (didn't bet) Seat 2: hastyboots (small blind) folded before Flop Seat 3: seula i (big blind) collected ($0.20) Seat 4: fr_kevin01 folded before Flop (didn't bet) Seat 5: limey05 folded before Flop (didn't bet) Seat 6: sanlu folded before Flop (didn't bet) Seat 7: Masterfrank folded before Flop (didn't bet) Seat 8: Refu$e2Lose folded before Flop (didn't bet) Seat 9: 1pepepe0114 folded before Flop (didn't bet) My problem is that I am not sure about how to proceed to parse the log file: the only knowledge I have is "manually" scanning line by line for a particular character or symbol, but I am afraid it would need exhaustive error handling. So I was wandering if there is any other techniques or better way to parse these poker hands? Many thanks for your help

    Read the article

  • Parsing a string

    - by sfactor
    i have a string of the format SUCCESS,12:34:56:78:90, i want to separate these two values that are separated by commas into two different strings. how do i do that in gcc using c language.

    Read the article

  • Parsing line and selecting values corresponding to a key

    - by gagneet
    there is a set of data which is arranged in a specific manner (as a tree), as is given below. basically a key=value pair, with some additional values at the end, which informs how many children does the branch have and some junk value. 11=1 123 2 11=1>1=45 234 1 11=1>1=45>9=16 345 1 11=1>1=45>9=16>2=34 222 1 11=1>1=45>9=16>2=34>7=0 2234 1 11=1>1=45>9=16>2=34>7=0>8=0 22345 1 11=1>1=45>9=16>2=34>7=0>8=0>0=138 22234 1 11=1>1=45>9=16>2=34>7=0>8=0>0=138>5=0 5566 1 11=1>1=45>9=16>2=34>7=0>8=0>0=138>5=0>4=0 664 1 11=1>1=45>9=16>2=34>7=0>8=0>0=138>5=0>4=0>6=10 443 1 11=1>1=45>9=16>2=34>7=0>8=0>0=138>5=0>4=0>6=10>3=11 445 0 11=1>1=47 4453 1 11=1>1=47>9=16 887 1 11=1>1=47>9=16>2=34 67 1 11=1>1=47>9=16>2=340>7=0 98 1 11=1>1=47>9=16>2=34>7=0>8=0 654 1 11=1>1=47>9=16>2=34>7=0>8=0>0=138 5789 1 11=1>1=47>9=16>2=34>7=0>8=0>0=138>5=0 9870 1 11=1>1=47>9=16>2=34>7=0>8=0>0=138>5=0>4=0 3216 1 11=1>1=47>9=16>2=34>7=0>8=0>0=138>5=0>4=0>6=10>3=11 66678 0 my problem is to get the appropriate branch from the above data, which satisfies exactly the values, which i give as the input. suppose, my input value to search in the above data stack are: 5=0 4=0 6=10 3=11 11=1 1=45 0=138 9=16 2=34 7=0 8=0 for the above given list of key-values, the function should return 11=11=459=162=347=08=00=1385=04=06=103=11 as the match. likewise, for another input file, in which another set of keys is given: 5=0 4=0 6=10 3=11 11=1 1=45 9=16 2=34 7=0 8=0 the function should return 11=11=459=162=347=08=0 1 as the match. not the last line; as that would also match all the values given in my input key, but, i want only the exact match. Also, I want to find out how many nodes were selected in the given array. (separated by ). What will be the best way to implement this kind of scenario?

    Read the article

  • Parsing JSON file with Python -> google map api

    - by Hannes
    Hi all, I am trying to get started with JSON in Python, but it seems that I misunderstand something in the JSON concept. I followed the google api example, which works fine. But when I change the code to a lower level in the JSON response (as shown below, where I try to get access to the location), I get the following error message for code below: Traceback (most recent call last): File "geoCode.py", line 11, in test = json.dumps([s['location'] for s in jsonResponse['results']], indent=3) KeyError: 'location' How can I get access to lower information level in the JSON file in python? Do I have to go to a higher level and search the result string? That seems very weird to me? Here is the code I have tried to run: import urllib, json URL2 = "http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false" googleResponse = urllib.urlopen(URL2); jsonResponse = json.loads(googleResponse.read()) test = json.dumps([s['location'] for s in jsonResponse['results']], indent=3) print test Thank you for your responses.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >