parsing

How to parse a string with spaces to integer

I have a string representing an integer with spaces -- digits are grouped by three. I was considering using strchr and strcat, as in: char* remove_spaces (char* s) { char* space; while (space = strchr(s, ' ')) { *space = '\0'; strcat(s, space + 1); } return s; } But, first, I'm not sure it is safe...

Literal character in C#

I want to compile my C# code. I was parsing a string by "....", string[] parts = line.Split(new[] { '....' }, 2); Then I got an error: Too many characters in character literal The line looks like this: abc.... starting word in english I think that I need to convert .... to =. Then everything would work fine. Is there any oth...

Java Email message Parser?

Is anyone familiar with a Java library that helps with parsing the fields (date, subject, from, to) of the email below? Message-ID: <19815303.1075861029555.JavaMail.ss@kk> Date: Wed, 6 Mar 2010 12:32:20 -0800 (PST) From: [email protected] To: [email protected] Subject: some subject Mime-Version: 1.0 Content-Type: text/plain...

PHP get from string

$var = '<img src="http://site.com/some_directory/filename.png"/&gt;'; png can be replaced with any extension. How to cut everything, except "filename" part? And write into new variable. In this case: $name = 'filename'; One more example: $var = '<img src="http://site.com/directory/subdirectory/Pakahontos.txt"/&gt;'; $name = 'Paka...

Ruby markup parser for custom markup language

I am looking for a Ruby markup parser (or helper) to convert a custom markup language to HTML. Something like Decoda does in the PHP world (see $code->addMarkup() function). Is there a good tool in the Ruby world? ...

Retrieve stock quote in CSV format and display on website

I am trying to retrieve a stock quote for EAG and embed it into a website. The only info I need to get is the current price and the change. I know Yahoo offers an API and the URL I want to use is http://download.finance.yahoo.com/d/quotes.csv?s=EAG&amp;f=l1n1 What I am lacking is the knowledge of how to parse the CSV file and display...

How, using regex, can I capture the outer HTML element, when the same element type is nested within it?

I'm trying to capture certain parts of HTML using regular expressions, and I've come across a situation which I don't know how to resolve. I've got an HTML fragment like this: <span ...> .... <span ...> ... </span> ... </span> so, a <span> element into which another <span> element is nested. I've been successfully using the followin...

Ideas for parsing a text file in C#

I'm wondering what would be the best way to parse this format: map= { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...

Parsing: load into memory or use stream

I'm writing a little parser and I would like to know the advantages and disadvantages of the different ways to load the data to be parsed. The two ways that I thought of are: Load the file's contents into a string then parse the string (access the character at an array position) Parse as reading the file stream (fgetc) The former wil...

Binary trees, construct a tree based on preorder

Hello, constructing a tree given it's inorder is easy enough. But, let's say you are supposed to construct a tree based on it's preorder (+ + y z + * x y z for example). It's easy to see that + is the root, and how to continue in the left subtree from there. But.. how do you know when you are supposed to "switch" to the right subtree? ...

Questions about parsing

I know we can grab information (with php) from any site and create own. I'm talking about parsing some additional content like movie information (dates, budget, persons, etc) or video file properties from youtube (size, duration). I'm excited on realizing of grabbing process from big sites and large amounts of information. Seems there...

Upload XML feed to mysql using PHP

Hi I have an XML feed coming in: <?xml version="1.0" encoding="UTF-8"?><product> <name>John</name> <contact_email>[email protected]</contact_email> <contact_telephone>01234 567</contact_telephone> <url>www.johnsone.com.com</url></product> I need to get this loaded to MySQL using php - have seen a few examples but all of them take a f...

Parsing MSDN Geometry Data Type

Hi, I have a database where one field gives spatial coordinates. I have learned the field is a serialised MSDN geometry Data Type (http://msdn.microsoft.com/en-us/library/bb933973.aspx). I want to access this database from Python and was wandering if anyone knew the format of the Geometry Data Type, or any libraries capable of parsing ...

How could I apply the class or the style to some HTML element in IE?

I'm doing an application that has to parse elements in an XML tree to HTML and in all the browsers it goes well but IE doesn't want to apply the styles to the elements. How could I fix this? function add2Doc(elmnt, domDoc, newEl) { /* * This function transform an * element to into the an acceptable * part of another ...

Eclipse ASTParser to parse only a java function?

Hi, I just wanna know using org.eclipse.jdt.core.dom.ASTParser if it is possible to parse only a java function? This is how I tried: I passed the code of a function to the ASTParser.setSource(char[] s) as follows: ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setSour...

Populate Nodes with Delimited String

My programmer's block is especially bad today, maybe you can help get me moving again?! Supplement I'm trying to parse out some CSV's from a legacy program we are trying to support. The part I'm trying to abstract is stored by the old program in a string "Channel.Device.Element1.Element2.Tag:Description" I am now storing this data ...

ERLANG - Splitting Lists into sub list

Hi this is my first post here hope you all are well. So Im just starting erlang and I ran into a problem im not sure how to tackle yet. So I have a binary I am recieving in the form of <<56, 23, 67, 34, 45, 78, 01, 54, 67, 87, 45, 53, 01, 34, 56, 78>> My goal is to split it into a sub list (or binary if more efficient) based on t...

how to convert/import/create a CSV file to excel (xlsx) using C# forms

Hi guys, I am trying to convert CSV file to MS Excel file. one of the issue, is that my CSV file , which I am getting from client, is not well formed. I tried to parse it with different approach but none of them end up with expected results. therefore I had to manually open the CSV file in Excel and save it as .xlsx and then use it for ...

Java: Parsing a text for words from a list (acronyms, abbr., etc)

Given: A text (optional with HTML tags) a database table with abbreviations and acronyms (like "etc.", "s.o.", ...) Goals: Build a parser that finds all occurrences in the given text Build a small gui to let the user choose if the found occurrence matches (this will be swing by demand) User has the option to ignore a matc...

Objective-C XML Parsing

Hi, I'm using this code to parse XML in the instance variable response: @implementation Delegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { MKFacebook *fbConnection = [[MKFacebook facebookWithAPIKey:@"----" delegate:self] retain]; [fbConnection login]; NSMutableDictionary *parameters = [[[NSMutableDictio...