parsing

Read co-ordinates from a txt files using C Program

Hey, I want to read cartesian coordinates of a large set of points from of a .txt file into a matrix or some such data structure using a C program. The file has contents of the type 023 435 1.0 23.5 12.5 0.2 : : : : : : : : : : : : and so on... There are about 4000 such co-ordinates in the file. First column i...

How to validate string can be convert to specific type?

I have string which might be int, datetime, boolean, byte etc'. How can i validate that the string can be convert into those types without using the TryParse of each type? ...

Crunching json with python

Echoing my other question now need to find a way to crunch json down to one line: e.g. {"node0":{ "node1":{ "attr0":"foo", "attr1":"foo bar", "attr2":"value with long spaces" } }} would like to crunch down to a single line: {"node0":{"node1":{"attr0":"foo","attr1":"foo bar","attr2":"value...

Parsing comma separated lines and calculating sum

So basically my problem can be written in pseudo-code as follows: split the line by = using value before =, find the next line check this the value after = matches previous if not, then loop till end of file collect all the values which match and using the line numbers, get the last 2 columns value sum all the values for a given set wit...

What's the algorithm of stackoverflow code parser?

So that the code snippet is colored. How? ...

Parse a string to a specified length (without cutting words)

I have a long string that I need to parse into an array of strings that do not exceed 40 characters in length. The tricky part of this for me is making sure that the regex finds the last whitespace before 40 characters to make a clean break between strings since I don't want words cut off. ...

How can I define an INI file grammar using the BNFC?

http://www.cs.chalmers.se/Cs/Research/Language-technology/BNFC/ how should I write my labeled BNF to get BNFC to generate a INI parser for me? I have only gotten so far o__O! entrypoints File ; comment "#" ; token ID ( letter | digit | ["-_'"] )+ ; Ini. File ::= [Section] ; Sect. Section ::= "[" ID "]" [Statement] ; Bind. Statement...

org.xml.sax.SAXParseException: The character reference must end with the ';' delimiter. Workaround Needed

I am trying to use DOM Parser in Java to parse a small XML file I pull off the net from its uri but receive an error complaining about missing semicolon. Here's link 108: Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("url_to_the_xml_file.xml"); Here's the error: [Fatal Error] A01.xml:6:53: The charac...

Difference between an LL and Recursive Descent parser?

I've recently being trying to teach myself how parsers (for languages/context-free grammars) work, and most of it seems to be making sense, except for one thing. I'm focusing my attention in particular on LL(k) grammars, for which the two main algorithms seem to be the LL parser (using stack/parse table) and the Recursive Descent parser ...

Is it possible to parse this nightmare using Perl?

I'm working on some doc file, that when copied and pasted into a text file, gives me the following sample 'output': ARTA215 ADVANCED LIFE DRAWING (3 Cr) (2:2) + Studio 1 hr. This advanced study in drawing with the life .... Prerequisite: ARTA150 Lab Fee Required ARTA220 CERAMICS II (3 Cr) (2:2) + Studio 1 hr. This course afford...

Reading in Malformed XML (unencoded XML entities) with PHP

Hi all, I'm having some trouble parsing malformed XML in PHP. In particular I'm querying a third party webservice that returns data in an XML format without encoding the XML entities in actual data. For example one of the the elements contains an ASCII heart, '<3', without the quotes, which the XML parser sees as an opening tag. It s...

A means of specifying pattern strings that drive parsing and formatting for arbitrary objects?

I'm building a general purpose data translation tool for internal enterprise use, using Java 5. The various departments use differing formats for coordinate information (latitudes/longitudes), and they want to see the data in their own format. For example, the coordinates of the White House in DMS format are 38° 53' 55.133" N, 77° 02...

Which XML parser for Haskell?

I'm trying to write some application, that performs analysis of data, stored in pretty big XML files (from 10 to 800MB). Each set of data is stored as single tag, with concrete data specified as attrobutes. I'm currently saxParse from HaXml, and I'm not satisfied with memory usage during work with it. On parsing of 15Mb XML file it cons...

how can I extract proper nouns from a string using php or javascript?

how can I extract proper nouns / numeric values from a string using php or javascript? example theres a string like Xyz visisted this page this page 53 mins ago. I want to be able to recognize "Xyz" and "53" as proper noun and numeric respectively ...

Get remote text file, process, and update database - approach and scripting language to use?

I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron. I think the idea would be for each type of feed, define the...

Parsing an unknown data structure in python

I have a file containing lots of data put in a form similar to this: Group1 { Entry1 { Title1 [{Data1:Member1, Data2:Member2}] Title2 [{Data3:Member3, Data4:Member4}] } Entry2 { ... } } Group2 { DifferentEntry1 { DiffTitle1 { ... } } } Thing is...

Parser builders for C#/.NET

Hey guys, I want to write a simple DSL in C#. Nothing too complicated. I'm looking for the .NET equivalent of Lex & Yacc. The easiest one I've found so far is GOLD Parser builder. The other choice is to use the lex & yacc available with F#, but I'm not keen to program in F# right now. If you have any suggestions for the .NET version of...

Javascript parser for simple expression

I would like to find a javascript parser that can handle and evaluate simple expressions. The parser should be able to evaluate the regular mathematical expressions, and support custom functions with parameters. It also has to support strings handling. String concatenation with || operator support is preferred, but it is okay if + will d...

How can I parse the output of /proc/net/dev into key:value pairs per interface using Python?

The output of /proc/net/dev on Linux looks like this: Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed lo:18748525 129811 0 0 0 0 0 0 18748525 129811 ...

Learning More About Parsing

I have been programming since 1999 for work and fun. I want to learn new things, and lately I've been focused on parsing, as a large part of my job is reading, integrating and analyzing data. I also have a large number of repetitive tasks that I think I could express in very simple domain-specific languages if the overhead was low enough...