Re: [Gambas-user] help with some simple parsing
You can use Replace$ to search and remove the \t character in your string. I am not so fluent in Gambas, but the good old VB6 does support (null string) as replacement, so I suppose that Gambas also do this. Just put your a_line there and search for any \t, replace with (null string)... Your text will get cleared ... Other point of mention: It will may be better to split also the a_line on the TAB char and thus receive semi-two dimensional array containing your values. Then you can start (re-)creating / displaying your data properly. kind regards Emil P.S. Are you physician? -Ursprungliche Nachricht- Von: richard terry [mailto:rte...@pacific.net.au] Gesendet: Mittwoch, 6. Mai 2009 15:02 An: mailing list for gambas users; Ian Haywood Betreff: [Gambas-user] help with some simple parsing See the attached file for the data. Unfortunately I'm brain dead when it comes to simple logic. 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. Any help appreciated. richard -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] help with some simple parsing
Il mercoledì 6 maggio 2009 15:01:45 richard terry ha scritto: See the attached file for the data. Unfortunately I'm brain dead when it comes to simple logic. 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. Any help appreciated. richard You can't use BR as a separator , because BR is a list of separators. This is why you miss some letters, Eg. Results, Bicarb. I will do a substitution with Replace$ to have a uniq splitting char. (I used @) eg.: PUBLIC SUB Main() DIM bits AS string[] DIM a_line AS String DIM sReplacedText AS String sReplacedText = Replace$(File.Load(sample_tabbed_text), BR, @) bits = Split(sReplacedText, @, , TRUE) FOR EACH a_line IN bits PRINT a_line NEXT END Saluti, Stefano -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] help with some simple parsing
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 signature.asc Description: This is a digitally signed message part. -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] help with some simple parsing
Hi Richard This code snippet will dump the text into a TextArea for you, it asumes (a bad thing) that there are no newline characters in the data and as such works with your sample. I used a button to launch the code... the important bits are in the middle... :) PUBLIC SUB ButtonGO_Click() DIM hFile AS File DIM LineInput AS String DIM ScrapString AS String DIM SPlitString AS String[] hFile = OPEN /home/bungayst/scrap/sample_tabbed_text FOR INPUT WHILE NOT Eof(hFile) LINE INPUT #hFile, LineInput WEND CLOSE hFile LineInput = Replace$(LineInput, BR, \n) TextArea1.Text = LineInput SplitString = Split(LineInput, \t) FOR EACH ScrapString IN SPlitString PRINT ScrapString NEXT END richard terry wrote: See the attached file for the data. Unfortunately I'm brain dead when it comes to simple logic. 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. Any help appreciated. richard -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] help with some simple parsing
Richard, See the attached file and let me know if this is the output you want. It is a HTML document. My approach is kind of different, probably the best way to handle this is by using the XML Writer. On Wed, May 6, 2009 at 8:52 AM, Stephen Bungay sbun...@csolve.net wrote: Hi Richard This code snippet will dump the text into a TextArea for you, it asumes (a bad thing) that there are no newline characters in the data and as such works with your sample. I used a button to launch the code... the important bits are in the middle... :) PUBLIC SUB ButtonGO_Click() DIM hFile AS File DIM LineInput AS String DIM ScrapString AS String DIM SPlitString AS String[] hFile = OPEN /home/bungayst/scrap/sample_tabbed_text FOR INPUT WHILE NOT Eof(hFile) LINE INPUT #hFile, LineInput WEND CLOSE hFile LineInput = Replace$(LineInput, BR, \n) TextArea1.Text = LineInput SplitString = Split(LineInput, \t) FOR EACH ScrapString IN SPlitString PRINT ScrapString NEXT END richard terry wrote: See the attached file for the data. Unfortunately I'm brain dead when it comes to simple logic. 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. Any help appreciated. richard -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] help with some simple parsing
Try the following. It is a complete different approach using the XML Writer. Try it as a console project, just make sure you the gb.xml is selected under PROJECT\PROPERTIES\COMPONENTS ' Gambas module file PUBLIC SUB Main() DIM docXML AS XmlWriter docXML = NEW XmlWriter 'this line is to save the xml document in your home folder docXML.Open(User.Home /DoctorRicky.html, TRUE) 'This part is the fancy CSS styling only is not important docXML.StartElement(style, [type, text/css]) docXML.Text(table.fancyTable {padding: 2pt; widht:100%;}) docXML.Text(th {font-weight: bold; background-color: #99; color: #00}) docXML.Text(tr.evenRow {background-color: #f5f5dc; text-align: center}) docXML.Text(tr.oddRow {background-color: #ff; text-align: center}) docXML.EndElement docXML.StartElement(table, [class, fancyTable]) 'th / is the HTML tab for the headers docXML.Element(th, Test) docXML.Element(th, Date 1) docXML.Element(th, Date 2) docXML.Element(th, Date 3) 'tr / is the tag for the rows docXML.StartElement(tr, [class, oddRow]) 'td / is the tag for the colums ' number of td / elements must be the same as the number of th / elements docXML.Element(td, LDL Fraction) docXML.Element(td, 50 ml/dl) docXML.Element(td, 100 ml/dl) docXML.Element(td, 150 ml/dl) docXML.EndElement() 'On the real life you'll prefer to handle this with a Loop Control Structure docXML.StartElement(tr, [class, evenRow]) docXML.Element(td, HDL Fraction) docXML.Element(td, 50 ml/dl) docXML.Element(td, 75 ml/dl) docXML.Element(td, 100 ml/dl) docXML.EndElement() docXML.EndElement() 'PRINT Xml.EndDocument END On Wed, May 6, 2009 at 7:01 AM, richard terry rte...@pacific.net.au wrote: See the attached file for the data. Unfortunately I'm brain dead when it comes to simple logic. 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. Any help appreciated. richard -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user MMain.module Description: Binary data -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] help with some simple parsing
Opps i uploaded the wrong file. Sorry. On Wed, May 6, 2009 at 9:50 PM, Sergio A. Hernandez info.g...@gmail.com wrote: Try the following. It is a complete different approach using the XML Writer. Try it as a console project, just make sure you the gb.xml is selected under PROJECT\PROPERTIES\COMPONENTS ' Gambas module file PUBLIC SUB Main() DIM docXML AS XmlWriter docXML = NEW XmlWriter 'this line is to save the xml document in your home folder docXML.Open(User.Home /DoctorRicky.html, TRUE) 'This part is the fancy CSS styling only is not important docXML.StartElement(style, [type, text/css]) docXML.Text(table.fancyTable {padding: 2pt; widht:100%;}) docXML.Text(th {font-weight: bold; background-color: #99; color: #00}) docXML.Text(tr.evenRow {background-color: #f5f5dc; text-align: center}) docXML.Text(tr.oddRow {background-color: #ff; text-align: center}) docXML.EndElement docXML.StartElement(table, [class, fancyTable]) 'th / is the HTML tab for the headers docXML.Element(th, Test) docXML.Element(th, Date 1) docXML.Element(th, Date 2) docXML.Element(th, Date 3) 'tr / is the tag for the rows docXML.StartElement(tr, [class, oddRow]) 'td / is the tag for the colums ' number of td / elements must be the same as the number of th / elements docXML.Element(td, LDL Fraction) docXML.Element(td, 50 ml/dl) docXML.Element(td, 100 ml/dl) docXML.Element(td, 150 ml/dl) docXML.EndElement() 'On the real life you'll prefer to handle this with a Loop Control Structure docXML.StartElement(tr, [class, evenRow]) docXML.Element(td, HDL Fraction) docXML.Element(td, 50 ml/dl) docXML.Element(td, 75 ml/dl) docXML.Element(td, 100 ml/dl) docXML.EndElement() docXML.EndElement() 'PRINT Xml.EndDocument END On Wed, May 6, 2009 at 7:01 AM, richard terry rte...@pacific.net.au wrote: See the attached file for the data. Unfortunately I'm brain dead when it comes to simple logic. 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. Any help appreciated. richard -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user