Loading ...
Sorry, an error occurred while loading the content.

Block Sorting

Expand Messages
  • Ray Shapp
    To All, This may or may not require a clip. Occasionally I need to sort an HTML page that contains about 55 rows. Each row contains a variable amount of html
    Message 1 of 13 , Mar 2, 2011
    • 0 Attachment
      To All,

      This may or may not require a clip.

      Occasionally I need to sort an HTML page that contains about 55 rows. Each
      row contains a variable amount of html markup describing one vehicle. The
      table grows by about five vehicles (rows) each year. See the page at
      http://www.classiccars.ws/sales/index.html

      Cars and trucks are at the top of the table and motorcycles are at the
      bottom. Within those sections, vehicles are ordered by year within
      manufacturer. The vehicle model can be listed randomly within year and
      manufacturer.

      Only about six to ten changes are made to the table every year (vehicles
      added or deleted). Most of the additions occur when a vehicle is restored
      although some are added immediately upon acquisition. Deletions occur when a
      vehicle is sold. Since this table doesn't change very often, I have been
      cutting and pasting the rows manually, but that's a little tedious and it is
      subject to error. My plan is to precede every row with a comment containing
      multiples of 1000 in a key such as "***1000***", "***2000***", "***3000***"
      etc. If a vehicle is added between say row six and seven, the comment for
      that vehicle would be "***6500***".

      My question: Do we have any clips in the Fookes libraries that would sort
      multi-line blocks of text based on a unique key sequence such as I have
      described?

      Note that the rows in the existing table begin with a sequence number. I
      would be willing to hand-code the sequence numbers after doing an automated
      sort of the rows.

      Thank you for your advice.

      Ray Shapp


      [Non-text portions of this message have been removed]
    • Ray Shapp
      To All, I should have added to my previous message that I will be sorting the two sections of the table separately. Motorcycles shouldn t be mixed in with
      Message 2 of 13 , Mar 2, 2011
      • 0 Attachment
        To All,

        I should have added to my previous message that I will be sorting the two
        sections of the table separately. Motorcycles shouldn't be mixed in with
        other types of vehicles.

        Also, here (below) is an excerpt showing the first three rows of HTML with
        the sort keys I am proposing.

        Thanks again.

        Ray Shapp


        <!-- table excerpt with keys -->

        <!-- ***1000*** -->
        <tr valign="center">
        <td align="right" height="50"><font color="#ffcc00">01</font></td>
        <td class="thumb" align="center" height="60"><a
        href="1925ahernsfox/index.html" name="01" target="_blank"><img class="thumb"
        src="tn_1925ahernsfox.jpg" alt="Click to see big picture (200x150 pixels; 11
        KB)" align="middle" border="2"></a> </td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">1925</font></td>
        <td align="center"><font color="#ffcc00" size="4">Aherns Fox</font>
        </td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">J-S-4</font></td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">$125,000</font></td>
        <td align="center">This vehicle is the finest original Ahrens Fox big
        six cylinder fire pumper on the planet. The Ahrens Fox trucks were regarded
        as the Duesenbergs of fire fighting equipment. 691 cid inline six cylinder T
        head engine. 175" wheelbase, 22 feet 8 inches long. 8 feet tall. Fully
        equipped and in spectacular running condition.</td>
        </tr>

        <!-- ***2000*** -->
        <tr valign="center">
        <td align="right" height="50"><font color="#ffcc00">02</font></td>
        <td class="thumb" align="center" height="60"><a
        href="1914americanunder/index.html" name="01" target="_blank"><img
        class="thumb" src="tn_1914americanunder.jpg" alt="Click to see big picture
        (200x150 pixels; 11 KB)" align="middle" border="2"></a> </td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">1914</font></td>
        <td align="center"><font color="#ffcc00" face="arial" size="4"> American
        Underslung </font></td>
        <td align="center"><font color="#ffcc00" face="arial" size="4">Model
        664</font></td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">$785,000</font></td>
        <td align="center"><font color="#ffcc00" face="arial" size="3">This
        very rare six cylinder, 70 horsepower car is from the Bill Harrah
        collection, and has recently won an AACA National First Place award at
        the Hershey Fall meet (2006). There are only three examples of this
        marquee known to exist. The other two examples are housed at the
        Nethercutt Museum in Sylmar, California and in the Crawford Museum in
        Ohio. This car is listed on page 74 in "Motor Cars Of The Golden Past"
        by Ken Purdy.</font></td>
        </tr>

        <!-- ***3000*** -->
        <tr valign="center">
        <td align="right" height="50"><font color="#ffcc00">0<font size="3"
        face="Arial">3</font></font></td>
        <td class="thumb" align="center" height="60"><a
        href="1935auburn/index.html" name="01" target="_blank"><img class="thumb"
        src="tn_1935auburn.jpg" alt="Click to see big picture (200x150 pixels; 11
        KB)" align="middle" border="2"></a> </td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">1935</font></td>
        <td align="center"><font color="#ffcc00" face="arial"
        size="4">Auburn</font></td>
        <td align="center"><font color="#ffcc00" face="arial" size="4">Model
        8-851 Supercharged Phaeton</font></td>
        <td align="center"><font color="#ffcc00" face="arial" size="4"><a href="
        http://www.classiccars.ws/contact/index.htm"><font size="4">Click</font></a>
        to check availability</font></td>
        <td align="center"><font color="#ffcc00" face="arial" size="3">This car
        is a good runner and is available now for sale before restoration. We have
        intentions of doing a full show restoration on this vehicle and will offer
        it for sale at a later date for <br><font color="#40dd40">$150,000.00 -
        $175,000.00</font></font></td>
        </tr>


        [Non-text portions of this message have been removed]
      • Axel Berger
        ... Do you happen to have any decent database software you re familiar with? This is what I would use and write an output report generating HTML table source
        Message 3 of 13 , Mar 2, 2011
        • 0 Attachment
          Ray Shapp wrote:
          > My question: Do we have any clips

          Do you happen to have any decent database software you're familiar with?
          This is what I would use and write an output "report" generating HTML
          table source code. That's how I mamage a growing amount of rad
          scientific literature and how I generate List in TeX and HTML and
          references sections in papers.

          The problem is, I have not yet found anything coming even near my old
          Atari program so I still need to fire up the emulator every time I need
          a database. Before I found NoteTab the same held true for my editor.

          On the Atari there were at least four good and powerful databases
          available. For Windows there seems to be nothing but the hard to use and
          very expensive Access, Open Office Base is said to be worthless. No idea
          how that came about, a database is such an important, versatile and
          often used bit od software for nearly everyone. I have heard it said,
          the old one coming with works was quite good.

          Axel
        • Don
          mysql or better yet a wordpress install written all over it
          Message 4 of 13 , Mar 2, 2011
          • 0 Attachment
            mysql or better yet a wordpress install written all over it

            > Do you happen to have any decent database software you're familiar with?
          • Ray Shapp
            Hi Axel and Don,
            Message 5 of 13 , Mar 2, 2011
            • 0 Attachment
              Hi Axel and Don,


              <<Do you happen to have any decent database software you're familiar with?>>

              Yes, I have Access. I haven't used it for generating reports, but I can
              learn.


              <<better yet a wordpress install written all over it>>

              I've never used Wordpress, but my impression is that it would also be a good
              tool in this applicaiton.


              Thank you both for the suggestions.

              Ray Shapp



              On Wed, Mar 2, 2011 at 2:49 PM, Axel Berger <Axel-Berger@...> wrote:

              >
              >
              > Ray Shapp wrote:
              > > My question: Do we have any clips
              >
              > Do you happen to have any decent database software you're familiar with?
              > This is what I would use and write an output "report" generating HTML
              > table source code. That's how I mamage a growing amount of rad
              > scientific literature and how I generate List in TeX and HTML and
              > references sections in papers.
              >
              > The problem is, I have not yet found anything coming even near my old
              > Atari program so I still need to fire up the emulator every time I need
              > a database. Before I found NoteTab the same held true for my editor.
              >
              > On the Atari there were at least four good and powerful databases
              > available. For Windows there seems to be nothing but the hard to use and
              > very expensive Access, Open Office Base is said to be worthless. No idea
              > how that came about, a database is such an important, versatile and
              > often used bit od software for nearly everyone. I have heard it said,
              > the old one coming with works was quite good.
              >
              > Axel
              >
              >


              [Non-text portions of this message have been removed]
            • Eb
              Ray, If the sections are delimited by blank lines, a quick an durty way might be to temporarily join each table row into a single line (unwrapped), sort the
              Message 6 of 13 , Mar 2, 2011
              • 0 Attachment
                Ray,

                If the sections are delimited by blank lines, a quick an durty way might be to temporarily join each table row into a single line (unwrapped), sort the lines by Modify/Sort/Ascending, and unjoin again.

                Your blank lines will have been sorted to the top, delete them and reinsert blank lines with the replace menu:

                Replace
                <!-- ***
                With
                ^P<!-- ***

                No clip needed.


                Cheers.

                Eb

                --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
                >
                > sections of the table separately. Motorcycles shouldn't be mixed in with
                > other types of vehicles.
              • Sheri
                Goofed and tried to post this reply online under a non-list member ID so I don t expect it to show up (but it might be a duplicate). You could put the rows
                Message 7 of 13 , Mar 2, 2011
                • 0 Attachment
                  Goofed and tried to post this reply online under a non-list member ID so
                  I don't expect it to show up (but it might be a duplicate).

                  You could put the rows into an otl outline with sortable text on the
                  header. Sort the outline, then remove the headers. Could be automated
                  with regex (but a slight hiccup would need addressing in your sample
                  text owing to a line break in the middle of one of the vehicle
                  manufacture names -- no line breaks allowed in outline headers).

                  Would it be simpler to use Excel?

                  Or, maybe you could attach some javascript to the page for live sorting
                  (and capture the resulting html).

                  Regards,
                  Sheri
                • Ray Shapp
                  Hi Eb and Sheri
                  Message 8 of 13 , Mar 2, 2011
                  • 0 Attachment
                    Hi Eb and Sheri


                    <<a quick an durty way might be to temporarily join each table row into a
                    > single line (unwrapped), sort the lines >>
                    >
                    > <<You could put the rows into an otl outline with sortable text on the
                    > header. Sort the outline, then remove the headers. Could be automated with
                    > regex (but a slight hiccup would need addressing in your sample text owing
                    > to a line break in the middle of one of the vehicle manufacture name>>
                    >

                    Both are good ideas. I'm experimenting with them both. Since each row begins
                    with the sort key in a comment, and the comments will become a permanent
                    part of the document, line breaks in manufacturer name will not be a
                    problem. These ideas are pretty slick because I won't need to mess with
                    Access or Excel or Java scripts.

                    I should have results to report tomorrow.

                    Many thanks.

                    Ray Shapp


                    On Wed, Mar 2, 2011 at 4:50 PM, Eb <ebbtidalflats@...> wrote:

                    >
                    >
                    > Ray,
                    >
                    > If the sections are delimited by blank lines, a quick an durty way might be
                    > to temporarily join each table row into a single line (unwrapped), sort the
                    > lines by Modify/Sort/Ascending, and unjoin again.
                    >
                    > Your blank lines will have been sorted to the top, delete them and reinsert
                    > blank lines with the replace menu:
                    >
                    > Replace
                    > <!-- ***
                    > With
                    > ^P<!-- ***
                    >
                    > No clip needed.
                    >
                    > Cheers.
                    >
                    > Eb
                    >
                    >
                    > --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
                    > >
                    > > sections of the table separately. Motorcycles shouldn't be mixed in with
                    > > other types of vehicles.
                    >
                    >
                    >


                    [Non-text portions of this message have been removed]
                  • Don
                    Right that would do it -- and you don t need the line breaks anyway -- that is what wordwrap is for.
                    Message 9 of 13 , Mar 2, 2011
                    • 0 Attachment
                      Right that would do it -- and you don't need the line breaks anyway --
                      that is what wordwrap is for.

                      > <<a quick an durty way might be to temporarily join each table row into a
                      >> single line (unwrapped), sort the lines >>


                      > Both are good ideas. I'm experimenting with them both.
                    • Ray Shapp
                      Hi Eb and Don,
                      Message 10 of 13 , Mar 2, 2011
                      • 0 Attachment
                        Hi Eb and Don,

                        <<Right that would do it -- and you don't need the line breaks anyway --
                        > that is what wordwrap is for.>>
                        >

                        Problem solved! The join/sort/split works perfectly. Done entirely within
                        NoteTab, and no clip required.

                        Thanks to all who responded - Axel, Don, Eb, Sheri. (Did you notice that you
                        folks replied in alphabetical order?)

                        Ray Shapp


                        On Wed, Mar 2, 2011 at 7:51 PM, Don <don@...> wrote:

                        >
                        >
                        > Right that would do it -- and you don't need the line breaks anyway --
                        > that is what wordwrap is for.
                        >
                        >
                        > > <<a quick an durty way might be to temporarily join each table row into a
                        > >> single line (unwrapped), sort the lines >>
                        >
                        > > Both are good ideas. I'm experimenting with them both.
                        >
                        >


                        [Non-text portions of this message have been removed]
                      • Eb
                        Yes, Microsoft s latest invention, the cloud queue. Each PC delays its posts until its turn. Except for Axel s. Germans are renowned for the ability to get
                        Message 11 of 13 , Mar 3, 2011
                        • 0 Attachment
                          Yes,

                          Microsoft's latest invention, the "cloud" queue. Each PC delays its posts until its turn. Except for Axel's. Germans are renowned for the ability to get to the head of the Q. (;-) The German National Motto, "Ich drängel doch nich!" is heard at every train, bus, and theater door.

                          Just kidding Axel.

                          Prost.

                          PS
                          actually, there might be a grain of truth to this motto. Back in the early 1920's the German Gubmint issued new money so fast, that people were getting paid twice a day, and rushed right to the store to spend it, as it would lose value so fast, that in the morning you might be able to buy a loaf of bread, and by lunch time, you would be lucky to get a slice from that loaf for the same money.

                          Before the off-topic police cranks their recliner forward, lets make this a clip:

                          H="Calculate Daily Inflation"
                          ^!Set %lunchtimeprice%=^?[Enter price at lunchtime]
                          ^!Set %breakfastprice%=^?[Enter price at breakfast]
                          ^!Set %inflation%=^$Calc(100*(^%lunchtimeprice%/^%breakfastprice%-1))$
                          ^!Info [L]Today's inflation was ^%inflation% percent.

                          Eb

                          --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
                          > ...

                          > Thanks to all who responded - Axel, Don, Eb, Sheri. (Did you notice that you
                          > folks replied in alphabetical order?)
                          >
                        • Art Kocsis
                          Hi Ray, Short answer: Do now. Long answer: Other posters have already beat me to the punch to use the join/split commands to solve your problem. I use that
                          Message 12 of 13 , Mar 6, 2011
                          • 0 Attachment
                            Hi Ray,

                            Short answer: Do now.

                            Long answer:

                            Other posters have already beat me to the punch to use the join/split
                            commands to solve your problem. I use that technique quite frequently.

                            Since I like to keep my original formatting, I add a unique temporary
                            character (such as %, &, #, etc) to the end of each non-empty line before
                            executing the join command and put two of these characters at the end
                            of the last line in each group. After sorting, the original formatting is
                            easily
                            restored by simply replacing each temporary character with a CRLF. This
                            also restores the empty line between groups.

                            Although it is pretty simple to do manually, a clip makes it even simpler so
                            why not dash off a quick clip? Answer: there is no such thing as a quick clip!

                            Not wanting to publish a clip that was not robust and did not handle abnormal
                            conditions, I ran into three problems:
                            - Multiple separator lines
                            - Oddities of high-bit characters
                            - Real life demands on my time

                            RegEx to the rescue for the first problem!

                            The second problem comes from wanting to use a temp character that would
                            have a very low probability of appearing in the document and a difference in
                            "mindset" between me and Notetab. To me high-bit characters such as thorn
                            (alt 0254) are special characters similar to &, #, etc but to Notetab they are
                            regular characters, i.e., they are word characters. So it is not a bug in
                            NT after
                            all that it can find a @ in @@ but cannot find a þ in þþ without the T option!

                            The third problem is self explanatory.

                            Interestingly, it turns out that I had written a clip to do this very thing
                            over two
                            years ago and forgot about it. I was pleased to see that I have made a bit of
                            progress in my coding, especially in the use of RegEx.

                            To the curious, I avoid "GoTos" unless absolutely necessary as it makes for
                            much more readable and error-free code.
                            ##################### Code follows: ###################
                            Sort Groups

                            ;Clip to sort (ascending), groups of lines of text, each group
                            ; consisting of one or more lines with each line terminated by an
                            ; EOL, and each group of lines separated by one or more blank lines
                            ;
                            ;Note: This clip will affect either preselected text only
                            ; or the entire document if no text is preselected
                            ;Note: the temporary character "þ" (Thorn, ANSI 254 = ALT 0254),
                            ; must not occur at any place in the selected text.
                            ;Note: "þ" is a word character, hence requires the "T" ^!Find option
                            ; #, @, $, %, etc are non-word chars & do not require the T option
                            ;Note: If you want to keep the group spacing for all groups, make sure
                            ; you include the CRLF on the last line

                            ;Rev History
                            ;03-06-11 Created Clip

                            ^!StatusShow Running Group Sort
                            ^!SetScreenUpdate Off
                            ;^!SetDebug On

                            ^!Set %SlctSz%=^$GetSelSize$
                            ^!If ^%SlctSz%=0 ^!Jump Doc_Start
                            ^!Find "þ" HST

                            ^!IfError Safe
                            ^!Continue Error: Text to be sorted contains internal test character "þ",
                            exiting clip
                            ^!Goto End

                            :Safe
                            ^!If ^%SlctSz%>0 ^!Replace "^P" >> "þ" AISTH
                            ^!If ^%SlctSz%>0 ^!Replace "þ{2,}" >> "þ\r\n" AIRSTH
                            ^!If ^%SlctSz%=0 ^!Replace "^P" >> "þ" AISTW
                            ^!If ^%SlctSz%=0 ^!Replace "þ{2,}" >> "þ\r\n" AIRSTW
                            ^!Toolbar Sort Ascending
                            ^!Replace "þ" >> "^P" AISTH
                            ^!If ^%SlctSz%=0 ^!Jump Doc_Start

                            ^!Continue Align Left or Cancel?
                            ^!Toolbar Left Align

                            ^!SetDebug Off
                            ##################### Code complete ##################

                            Namaste', Art

                            At 03/02/2011 11:26, Ray wrote:
                            >To All,
                            >
                            >My question: Do we have any clips in the Fookes libraries that would sort
                            >multi-line blocks of text based on a unique key sequence such as I have
                            >described?
                          • Ray Shapp
                            Hello Art, That s a major piece of work. I ll definitely use it. Many thanks! Ray Shapp ... [Non-text portions of this message have been removed]
                            Message 13 of 13 , Mar 7, 2011
                            • 0 Attachment
                              Hello Art,

                              That's a major piece of work. I'll definitely use it.

                              Many thanks!

                              Ray Shapp


                              On Sun, Mar 6, 2011 at 2:55 PM, Art Kocsis <artkns@...> wrote:

                              >
                              >
                              > Hi Ray,
                              >
                              > Short answer: Do now.
                              >
                              > Long answer:
                              >
                              > Other posters have already beat me to the punch to use the join/split
                              > commands to solve your problem. I use that technique quite frequently.
                              >
                              > Since I like to keep my original formatting, I add a unique temporary
                              > character (such as %, &, #, etc) to the end of each non-empty line before
                              > executing the join command and put two of these characters at the end
                              > of the last line in each group. After sorting, the original formatting is
                              > easily
                              > restored by simply replacing each temporary character with a CRLF. This
                              > also restores the empty line between groups.
                              >
                              > Although it is pretty simple to do manually, a clip makes it even simpler
                              > so
                              > why not dash off a quick clip? Answer: there is no such thing as a quick
                              > clip!
                              >
                              > Not wanting to publish a clip that was not robust and did not handle
                              > abnormal
                              > conditions, I ran into three problems:
                              > - Multiple separator lines
                              > - Oddities of high-bit characters
                              > - Real life demands on my time
                              >
                              > RegEx to the rescue for the first problem!
                              >
                              > The second problem comes from wanting to use a temp character that would
                              > have a very low probability of appearing in the document and a difference
                              > in
                              > "mindset" between me and Notetab. To me high-bit characters such as thorn
                              > (alt 0254) are special characters similar to &, #, etc but to Notetab they
                              > are
                              > regular characters, i.e., they are word characters. So it is not a bug in
                              > NT after
                              > all that it can find a @ in @@ but cannot find a � in �� without the T
                              > option!
                              >
                              > The third problem is self explanatory.
                              >
                              > Interestingly, it turns out that I had written a clip to do this very thing
                              >
                              > over two
                              > years ago and forgot about it. I was pleased to see that I have made a bit
                              > of
                              > progress in my coding, especially in the use of RegEx.
                              >
                              > To the curious, I avoid "GoTos" unless absolutely necessary as it makes for
                              > much more readable and error-free code.
                              > ##################### Code follows: ###################
                              > Sort Groups
                              >
                              > ;Clip to sort (ascending), groups of lines of text, each group
                              > ; consisting of one or more lines with each line terminated by an
                              > ; EOL, and each group of lines separated by one or more blank lines
                              > ;
                              > ;Note: This clip will affect either preselected text only
                              > ; or the entire document if no text is preselected
                              > ;Note: the temporary character "�" (Thorn, ANSI 254 = ALT 0254),
                              > ; must not occur at any place in the selected text.
                              > ;Note: "�" is a word character, hence requires the "T" ^!Find option
                              > ; #, @, $, %, etc are non-word chars & do not require the T option
                              > ;Note: If you want to keep the group spacing for all groups, make sure
                              > ; you include the CRLF on the last line
                              >
                              > ;Rev History
                              > ;03-06-11 Created Clip
                              >
                              > ^!StatusShow Running Group Sort
                              > ^!SetScreenUpdate Off
                              > ;^!SetDebug On
                              >
                              > ^!Set %SlctSz%=^$GetSelSize$
                              > ^!If ^%SlctSz%=0 ^!Jump Doc_Start
                              > ^!Find "�" HST
                              >
                              > ^!IfError Safe
                              > ^!Continue Error: Text to be sorted contains internal test character "�",
                              > exiting clip
                              > ^!Goto End
                              >
                              > :Safe
                              > ^!If ^%SlctSz%>0 ^!Replace "^P" >> "�" AISTH
                              > ^!If ^%SlctSz%>0 ^!Replace "�{2,}" >> "�\r\n" AIRSTH
                              > ^!If ^%SlctSz%=0 ^!Replace "^P" >> "�" AISTW
                              > ^!If ^%SlctSz%=0 ^!Replace "�{2,}" >> "�\r\n" AIRSTW
                              > ^!Toolbar Sort Ascending
                              > ^!Replace "�" >> "^P" AISTH
                              > ^!If ^%SlctSz%=0 ^!Jump Doc_Start
                              >
                              > ^!Continue Align Left or Cancel?
                              > ^!Toolbar Left Align
                              >
                              > ^!SetDebug Off
                              > ##################### Code complete ##################
                              >
                              > Namaste', Art
                              >
                              > At 03/02/2011 11:26, Ray wrote:
                              > >To All,
                              >
                              > >
                              > >My question: Do we have any clips in the Fookes libraries that would sort
                              > >multi-line blocks of text based on a unique key sequence such as I have
                              > >described?
                              >
                              >
                              >


                              [Non-text portions of this message have been removed]
                            Your message has been successfully submitted and would be delivered to recipients shortly.