Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Merging cells from two lines

 [1/4] from: john:thousand-hills at: 24-Aug-2001 23:07


I have an array that spits out from Oracle in an ASCII Tab Separated Values. I have greatly shortened it here, lines 5 and 6. MMEA LAMA GUAD GUAD SHER BATT CONG WMCA Forming an HTML file, it comes out like this: <TR><TD>MMEA</TD><TD>LAMA</TD><TD>GUAD</TD><TD>GUAD</TD></TR> <TR><TD>SHER</TD><TD>BATT</TD><TD>CONG</TD><TD>WMCA</TD></TR> Using this code: s62: pick data 62 replace/all s62 tab "</CENTER></TD><TD><CENTER>" s62: rejoin [ "<tr bordercolor=gold border=1 bgcolor=white><TD><CENTER>" s62 </CENTER></TD></tr> ] s63: pick data 63 replace/all s63 tab "</CENTER></TD><TD><CENTER>" s63: rejoin [ "<tr bordercolor=gold border=1 bgcolor=white><TD><CENTER>" s63 </CENTER></TD></tr> ] I need to merge the two lines together by words in order: <TR><TD>MMEA SHER</TD><TD>LAMA BATT</TD><TD>GUAD CONG</TD><TD>GUAD WMCA</TD></TR> Any help?

 [2/4] from: arolls::bigpond::net::au at: 25-Aug-2001 15:58


You should combine the two lines, then convert the tabs to html as you have done already. Combining the lines: You need to read two lines at a time. (I am assuming each line is separated by a newline). ;block: read/lines %file.txt ; gives you a block of strings ;example block block: ["MMEA^-LAMA^-GUAD^-GUAD" "SHER^-BATT^-CONG^-WMCA"] foreach [s1 s2] block [ ;print [s1 s2] ; split by whitespace (includes tab) and return a block b1: parse s1 "" b2: parse s2 "" ; combine s1 and s2 s: copy "" repeat n length? b1 [ append s reduce [b1/:n " " b2/:n tab] ] probe s: copy/part s back tail s ; chop off last tab ; now perform your conversion of tabs to html as below ]

 [3/4] from: john:thousand-hills at: 25-Aug-2001 7:51


Anton: This looks great. I will put it in the script this evening. It has taken me a year to convince our IT Manager and Network Manager to accept code written in REBOL. I am the Web Development Guy, and they and the 5 other department programmers (all good programmers and dynamite people) have been against using REBOL in favor of PERL, C++, Visual Basic, Sequal Loader, and Oracle Screens. Now they are seeing what I keep showing them, written almost in English and so few lines of code. My boss has signed off on purchasing REBOL, now the others are borrowing the books she bought for me, and asking questions. Most impressive is the making and passing of text and HTML files via E-Mail without BLAT or MAILIT and its cross platform capabilities where the documentation takes more lines than does the code.. This is saving me a lot of time. Thanks guys. John At 03:58 PM 8/25/2001 +1000, you wrote:

 [4/4] from: john:thousand-hills at: 26-Aug-2001 8:04


In reading and displaying lines of data from a text array with this script: data: read/lines %route.txt d7: pick data 7 s7: pick data 7 replace/all s7 tab "</CENTER></TD><TD><CENTER>" s7: rejoin [ "<tr bordercolor=lightblue border=1 bgcolor=white><TD> <CENTER>" s7 "</CENTER></TD></tr>" ] either d7 [ print s7 ] [ "" ] How can I turn the printed elements in that line to reflect a change from " 04:30 " to read " 04:30AM " or " 16:30 " to read " 04:30PM " ? ..JOHN