Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parsing plain file into html

 
Alex Dubin
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have a plan file that looks something like this:


This is how file looks in plain form and this is how html source code looks if I view the source code in the browser. Of course when I view the page in the browser it does not look like this because there is no spacing between columns and fields because there is no formatting.
Before I start to write my own parser, is there a parser out there already that can create an html file from this file using tables? I have one approach to replace all spaces with  , but it's not very elegant.
Any help is appreciated!

thanks,
Alex

[ August 31, 2005: Message edited by: Alex Dubin ]
[ August 31, 2005: Message edited by: Alex Dubin ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your input I think this will be a manual process, not something you'll find already written.

HTML tables are the easiest way to align columns. So you want to generate:

How will you parse the id, name and phone out of each row of your file? It looks like they are in fixed positions so you can use substring. Does that give you some ideas?

I said there is probably not a general solution, but in fact Wiki sites render plain text into HTML for a living. Tables usually have some special delimiter to help:

Full Wiki markup is non-trivial but fascinating. Look at the source for Fit or Fitnesse for an education.
 
Alex Dubin
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks man!
This is exectly what I need!

Alex
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <PRE> tag is also meant to preserve the formatting of the text in between its opening and closing tags, so that might help you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic