views:

224

answers:

5

The problem: You have some data and your program needs specified input. For example strings which are numbers. You are searching for a way to transform the original data in a format you need. And the problem is: The source can be anything. It can be XML, property lists, binary which contains the needed data deeply embedded in binary junk. And your output format may vary also: It can be number strings, float, doubles....

You don't want to program. You want routines which gives you commands capable to transform the data in a form you wish. Surely it contains regular expressions, but it is very good designed and it offers capabilities which are sometimes much more easier and more powerful.


ADDITION:

Many users have this problem and hope that their programs can convert, read and write data which is given by other sources. If it can't, they are doomed or use programs like business intelligence. That is NOT the problem. I am talking of a tool for a developer who knows what is he doing, but who is also dissatisfied to write every time routines in a regular language. A professional data manipulation tool, something like a hex editor, regex, vi, grep, parser melted together accessible by routines or a REPL.

If you have the spec of the data format, you can access and transform the data at once. No need to debug or plan meticulously how to program the transformation. I am searching for a solution because I don't believe the problem is new.


It allows:

  • joining/grouping/merging of results
  • inserting/deleting/finding/replacing
  • write macros which allows to execute a command chain repeatedly
  • meta-grouping (lists->tables->n-dimensional tables)

Example (No, I am not looking for a solution to this, it is just an example): You want to read xml strings embedded in a binary file with variable length records. Your tool reads the record length and deletes the junk surrounding your text. Now it splits open the xml and extracts the strings. Being Indian number glyphs and containing decimal commas instead of decimal points, your tool transforms it into ASCII and replaces commas with points. Now the results must be stored into matrices of variable length....etc. etc.

I am searching for a good language / language-design and if possible, an implementation. Which design do you like or even, if it does not fulfill the conditions, wouldn't you want to miss ?

EDIT: The question is if a solution for the problem exists and if yes, which implementations are available. You DO NOT implement your own sorting algorithm if Quicksort, Mergesort and Heapsort is available. You DO NOT invent your own text parsing method if you have regular expressions. You DO NOT invent your own 3D language for graphics if OpenGL/Direct3D is available. There are existing solutions or at least papers describing the problem and giving suggestions. And there are people who may have worked and experienced such problems and who can give ideas and suggestions. The idea that this problem is totally new and I should work out and implement it myself without background knowledge seems for me, I must admit, totally off the mark.

UPDATE: Unfortunately I had less time than anticipated to delve in the subject because our development team is currently in a hot phase. But I have contacted the author of TextTransformer and he kindly answered my questions.
I have investigated TextTransformer (http://www.texttransformer.de) in the meantime and so far I can see it offers a complete and efficient solution if you are going to parse character data.

For anyone who will give it a try to implement a good parsing language, the smallest set of operators to directly transform any input data to any output data if (!) they were powerful enough seems to be:

  • Insert/Remove: Self-explaining

  • Group/Ungroup: Split the input data into a set of tokens and organize them into groups and supergroups (datastructures, lists, tables etc.)

  • Transform

    • Substituition: Change the content of the tokens (special operation: replace)
    • Transposition: Change the order of tokens (swap,merge etc.)
+3  A: 

For a programmer, I would suggest:

Perl against a SQL backend.

For a non-programmer, what it sounds like you're looking for is some sort of business intelligence suite.

Paul Nathan
Hi Nathan,while Perl is extremely powerful with character parsing, it is still a programming language intended for other tasks. What I search is a light version specialized for general parsing and as small and elegant as possible.lex, yacc etc. are more specialized for tokenizing and compiler building and I don't have the impression that they are intendedas tools.Why do you propose SQL ? I am intending to parse data from any input source (file,pipe,console etc.), not only database input.
Thorsten S.
@Thorsten: Perl has a large community and a large library of modules that can access a wide variety of data formats. It has been used for text report generation for years(but supports binary as well). Perl lexes trivially(built-in regex support) and there is a grammar module(recursive descent parsing). I suggest SQL to store your information. I agree that Perl is not a domain-specific language, which is why I recommend reviewing Business Intelligence suites and their capabilities, since it sounds like that's what you're really looking for in some fashion.
Paul Nathan
I have added more additional info. No, I am definitely not searching for BI, but for something much more advanced. I am a bit surprised that it seems to be hard to understand; I thought every programmer had the "pleasure" to write throwaway code to encode/decode some stupid data format. I can understand that SQL would support the n-dimensional grouping demanded, but I am not really excited by relational databases: not everything is a table and should be stored as one.
Thorsten S.
@Thorsten: My gut reaction is that you're looking for a silver bullet for a quite hard problem. But - this is just data grabbing and manipulating. Shouldn't be that hard, right? But I've never heard of such a thing (mind you, mass data analysis is not a field I've really worked in, soooo I'm not fully knowledgeable here.). If you hear of a language/software package that does what you want, I'd love to hear about it.
Paul Nathan
+3  A: 

This suggestion may broaden the scope of your search too much... but here it is:

You could either reuse, as-is, or otherwise get "inspiration" from the [open source] code of the SnapLogic framework.

Edit (answering the comment on SnapLogic documentation etc.)
I agree, the SnapLogic documentation leaves a bit to be desired, in particular for people in your situation, i.e. when just trying to quickly get an overview of what SnapLogic can do, and if it would generally meet their needs, without investing much time and learn the system in earnest.
Also, I realize that the scope and typical uses of of SnapLogic differ, somewhat, from the requirements expressed in the question, and I should have taken the time to better articulate the possible connection.
So here goes...

A salient and powerful feature of SnapLogic is its ability to [virtually] codelessly create "pipelines" i.e. processes made from pre-built components; Components addressing the most common needs of Data Integration tasks at-large are supplied with the SnapLogic framework. For example, there are components to

  • read in and/or write to files in CSV or XML or fixed length format
  • connect to various SQL backends (for either input, output or both)
  • transform/format [readily parsed] data fields
  • sort records
  • join records for lookup and general "denormalized" record building (akin to SQL joins but applicable to any input [of reasonnable size])
  • merge sources
  • Filter records within a source (to select and, at a later step, work on say only records with attribute "State" equal to "NY")
  • see this list of available components for more details

A relatively weak area of functionality of SnapLogic (for the described purpose of the OP) is with regards to parsing. Standard components will only read generic file formats (XML, RSS, CSV, Fixed Len, DBMSes...) therefore structured (or semi-structured?) files such as the one described in the question, with mixed binary and text and such are unlikely to ever be a standard component.
You'd therefore need to write your own parsing logic, in Python or Java, respecting the SnapLogic API of course so the module can later "play nice" with the other ones.
BTW, the task of parsing the files described could be done in one of two ways, with a "monolithic" reader component (i.e. one which takes in the whole file and produces an array of readily parsed records), or with a multi-component approach, whereby an input component reads in and parse the file at "record" level (or line level or block level whatever this may be), and other standard or custom SnapLogic components are used to create a pipeline which effectively expresses the logic of parsing a record (or block or...) into its individual fields/attributes.
The second approach is of course more modular and may be applicable if the goal is to process many different files format, whereby each new format requires piecing together components with no or little coding. Whatever the approach used for the input / parsing of the file(s), the SnapLogic framework remains available to create pipelines to then process the parsed input in various fashion.

My understanding of the question therefore prompted me to suggest SnapLogic as a possible framework for the problem at hand, because I understood the gap in feature concerning the "codeless" parsing of odd-formatted files, but also saw some commonality of features with regards to creating various processing pipelines.
I also edged my suggestion, with an expression like "inspire onself from", because of the possible feature gap, but also because of the relative lack of maturity of the SnapLogic offering and its apparent commercial/open-source ambivalence.
(Note: this statement is neither a critique of the technical maturity/value of the framework per-se, nor a critique of business-oriented use of open-source, but rather a warning that business/commercial pressures may shape the offering in various direction)

To summarize:
Depending on the specific details of the vision expressed in the question, SnapLogic may be worthy of consideration, provided one understands that "some-assembly-required" will apply, in particular in the area of file parsing, and that the specific shape and nature of the product may evolve (but then again it is open source so one can freeze it or bend it as needed).
A more generic remark is that SnapLogic is based on Python which is a very swell language for coding various connectors, convertion logic etc.

mjv
Hi, did you use SnapLogic ?I have looked at the tutorial, but it seems a bit uninformative. Are there routines inside SnapLogic which are more explaining or do you have a site with more information ?
Thorsten S.
@Thorsten S: See my [long] edit. I hope this gives you a better understanding of what SnapLogic may, or may not, do for you.
mjv
Many thanks for your long explanation. I have added more information to my furter approach to the title comments.
Thorsten S.
+4  A: 

Have you investigated TextTransformer?

I have no experience with this, but it sounds pretty good and the author makes quite competent posts in the comp.compilers newsgroup.

You still have to some programming work.

Ira Baxter
http://www.texttransformer.com/Description_en.html sounds exactly like the problem I am trying to solve. I will contact the author, many thanks.
Thorsten S.
+2  A: 

In reply to Paul Nathan you mentioned writing throwaway code as something rather unpleasant. I don't see why it should be so. After all, all of our code will be thrown away and replaced eventually, no matter how perfect we wrote it. So my opinion is that writing throwaway code is pretty much ok, if you don't spend too much time writing it.

So, it seems that there are two approaches to solving your solution: either a) find some specific tool intended for the purpose (parse data, perform some basic operations on it and storing it in some specific structure) or b) use some general purpose language with lots of libraries and code it yourself.

I don't think that approach a) is viable because sooner or later you'll bump into an obstacle not covered by the tool and you'll spend your time and nerves hacking the tool, or mailing the authors and waiting for them to implement what you need. I might as well be wrong, so please if you find a perfect tool, drop here a link (I myself am doing lots of data processing in my day job and I can't swear that I couldn't do it more efficiently).

Approach b) may at first seem "unpleasant", but given a nice high-level expressive language with bunch of useful libraries (regexps, XML manipulation, creating parsers...) it shouldn't be too hard, and may be gradually turned into a DSL for the very purpose. Beside Perl which was already mentioned, Python and Ruby sound like good candidates for these languages (I bet some Lisp derivatives too, but I have no experience there).

Mladen Jablanović
Thorsten S.
Addendum: You are right that I will sooner or later find an unsolvable problem, but which tool (no programming language) is able to solve all problems ? If I find sth which do the job 90% of the time, I would be very pleased. And sure, if I find sth cool I will share it here.
Thorsten S.
+1  A: 

You might find AntlrWorks useful if you go so far as defining formal grammars for what you're parsing.

Andy Dent