[Gambas-user] help with some simple parsing

Rolf Schmidt rolf.frogs at ...221...
Wed May 6 17:03:38 CEST 2009


Hi Richard

> In one of my hl7 messages in the Free Text segment under an actual
> pathology result, there is a list of sequential bood test results
> representing previous results of the same type - , separated by tabs which
> I need to display properly. as I've re-constructed the result as html, the
> tabs simply disappear in the result, so I've been looking for a solution,
> and to start I thought maybe I could split this up into lines and then
> later put it into a table embedded in the html to keep it aligned.
>
> Perhaps there is a simple way out, but this is what I've done so far.
>
> So I started with this:
>
> 1) Split this into lines
>
> Dim bits as string[]
> dim a_line as string
>
> bits = split(the_text_in_the_file,"<BR>,"", TRUE)
>
> for each a_line in bits
> 	print a_line
> next
>
> Problem with this is that the \t (I presume tab character) gets in the way,
> and it dosn't split properly with the results of the bits[] as shown in the
> picture. Interestingly an occasional letter is lost off the test names.

I didn't find any \t-char in your file. But I think it is a table, where the 
first line hold the column headers and each line starts with a word. So I 
suggest, that you keep the newline - perhaps the char which you substitute 
with the <br>-Tag - as it is. Then compress all spaces to one space and 
substitute this to \t (i.e. tab-chars).
A shell command like the follwoing one will do this:

cat sample_text | tr -s ' '  | tr ' ' \t > converted_text

(Perhaps a gambas-guru can translate the line in a simple Gambas statement)

Now you can split your converted_text in an array of lines. Use the first 
array entry for your the column headers of a listview (but split the line by 
the \t char)

Do the same for all the other lines and you will get a nice table.
Of course you can create a html-table as well, if you have your data in the 
suggested format.

Hope that helps
Rolf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090506/b2727947/attachment.sig>


More information about the User mailing list