PDA

View Full Version : Need a text post processor



pendell
2013-07-25, 03:38 PM
Okay. I need a text postprocessor to quickly read a text file and spit it out in a new format. I'm thinking perl or Nawk. Any other suggestions?

Respectfully,

Brian P.

valadil
2013-07-25, 03:52 PM
Sed? What formats are you going to/from? There might be something specific out there for you.

pendell
2013-07-28, 07:56 AM
At this point I can pretty much choose my format, so long as it doesn't look terrible. I'm thinking to spit it out in .HTML or .XML format.

Respectfully,

Brian P.

Manga Shoggoth
2013-07-28, 08:09 AM
Well, if you are reading a data file (well defined fields) and embedding the HTML yourself, then *awk will work really well. I've used variants of awk for text postprocessing and it is (relatively) easy.

If your word processor has the appropriate "save as" facilities you could also use the word processor's mail-merge functionallity.

I have no experience with perl, however.

shawnhcorey
2013-07-28, 09:44 AM
I have plenty of experience with Perl, in case you have any questions.

What format is the text file in? Are paragraphs separated by a blank line? Does it have embedded codes for bold, italic, and links? Does it have images? Does it have verbatim paragraphs?

IF you are writing the text files yourself, you may want to consider writing them in POD (Plain Old Documentation) format (http://perldoc.perl.org/perlpod.html) since Perl comes with pod2html which converts POD files to HTML pages.

pendell
2013-07-28, 04:07 PM
I have plenty of experience with Perl, in case you have any questions.

What format is the text file in? Are paragraphs separated by a blank line? Does it have embedded codes for bold, italic, and links? Does it have images? Does it have verbatim paragraphs?

IF you are writing the text files yourself, you may want to consider writing them in POD (Plain Old Documentation) format (http://perldoc.perl.org/perlpod.html) since Perl comes with pod2html which converts POD files to HTML pages.

I plan to pull a SQL text line query and pipe it to a file. This will be text output. I'm going to see if I can play around with it to format the result of the query as .CSV . Once it's in .CSV format, I need something to suck it in and spit it out in a "pretty" format. I get to define what that means, so I'm thinking about using HTML tags to format it.

The trick is to knock out something quickly, in days not weeks, using off the shelf technology and no in-depth programming.

Respectfully,

Brian P.

valadil
2013-07-29, 08:36 AM
I'm going to see if I can play around with it to format the result of the query as .CSV .

I'm not sure if it's the best way, but concat_ws has worked for me. Personally I'd rather go straight from sql to markup than sql to csv to markup.

Erloas
2013-07-31, 09:55 PM
If you are trying to take information out of SQL and make it look pretty... isn't that what every report function in every database program does already?

I also think Excel and OpenOffice Calc both have ways of importing from SQL directly and it is generally pretty easy to make stuff look pretty in either of those. Might need a bit of VBA to do some things but I would imagine it would be pretty straight forward programming.