Flip a Table
I have tables containing data in reverse chronological order. I'd like it to be chronological so I'm thinking I can just move the table rows around. Seems like it would require a separate scratch file to hold the re-ordered rows until all rows have been copied, then replace the selection with the re-ordered rows. I.e., Take the last table row (cutting or removing it) from the selection and move it to the scratch area. Take the last table row and move it to the end of the scratch area. Lather, rinse, repeat until all rows have been cut from the original Then move the scratch contents to the original document. I'm guessing that Perl is the best tool for this job. It has a reverse function so I'm guessing that the original selection could be read into an array, using tr and /tr as delimiters, then regurgitated in reverse order of the original. Anyone have something like this lying around or an example showing how to get table rows into an array? -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group.
Re: Flip a Table
At 10:37 -0700 7/5/10, Warren Michelsen wrote: I have tables containing data in reverse chronological order. I'd like it to be chronological so I'm thinking I can just move the table rows around. Seems like it would require a separate scratch file to hold the re-ordered rows until all rows have been copied, then replace the selection with the re-ordered rows. I.e., Take the last table row (cutting or removing it) from the selection and move it to the scratch area. Take the last table row and move it to the end of the scratch area. Lather, rinse, repeat until all rows have been cut from the original Then move the scratch contents to the original document. I'm guessing that Perl is the best tool for this job. It has a reverse function so I'm guessing that the original selection could be read into an array, using tr and /tr as delimiters, then regurgitated in reverse order of the original. If the stuff between tr and /tr has a numeric value or a date between embedded in the rows with td and /td flags it would be fairly simple to store each row in a perl hash keyed to the date item. It's then a standard operation to pick up the keys in a sorted array which can be sequentially used to recall the strings from the hash in any order you want. I have done things like that but it's probably easier to start afresh than to look for old code. Ask. off line but leave the subject as-is to get by filters. -- -- Give me liberty or give me Obamacare -- -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group.
Re: Flip a Table
On 7/5/10 at 10:37 AM, wmichel...@gmail.com (Warren Michelsen) wrote: I have tables containing data in reverse chronological order. I'd like it to be chronological so I'm thinking I can just move the table rows around. Seems like it would require a separate scratch file to hold the re-ordered rows until all rows have been copied, then replace the selection with the re-ordered rows. This can be done in BBEdit with out a separate scratch file as follows: Go to Text-Add/Remove Line Numbers... Add suitable line numbers to the lines you want to reverse the order of with a space between the line number and data you want retained. Then to to Text-Sort Lines... Select Numbers match by value and Reverse sort. Finally go back to Add/Remove Line Numbers... to remove the line numbers previously added. The result will be a reverse order of the data. -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group.
Re: Flip a Table
At 12:48 PM -0700 on 7/5/10, Bill Rowe wrote about Re: Flip a Table: On 7/5/10 at 10:37 AM, wmichel...@gmail.com (Warren Michelsen) wrote: I have tables containing data in reverse chronological order. I'd like it to be chronological so I'm thinking I can just move the table rows around. Seems like it would require a separate scratch file to hold the re-ordered rows until all rows have been copied, then replace the selection with the re-ordered rows. This can be done in BBEdit with out a separate scratch file as follows: Go to Text-Add/Remove Line Numbers... Add suitable line numbers to the lines you want to reverse the order of with a space between the line number and data you want retained. Then to to Text-Sort Lines... Select Numbers match by value and Reverse sort. Finally go back to Add/Remove Line Numbers... to remove the line numbers previously added. The result will be a reverse order of the data. This would work BUT first you would need to make sure that each row (from tr to /tr) is a single line of HTML. If the row is spread over more than one line of HTML, the sort will not produce the correct order. The simplest way of doing this is to highlight the section of code that represents the rows, use format=compact to make all of it a single line, and then do a find/replace of the section to add new line codes (\r) after each /tr. IOW: Find /tr and replace with /tr\r. -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group.
Re: Flip a Table
At 9:48 PM +0100 7/5/10, John Delacour sent email regarding Re: Flip a Table: At 10:37 -0700 5/7/10, Warren Michelsen wrote: ...I'm guessing that Perl is the best tool for this job. It has a reverse function so I'm guessing that the original selection could be read into an array, using tr and /tr as delimiters, then regurgitated in reverse order of the original. How you do it will depend on where your line-breaks are. If your file reads tr1/tr tr2/tr tr3/tr tr4/tr tr5/tr then it is simple. Just write the following little routine, select the lines in the document you want to reverse and run the script. #UNIX SCRIPT: Is this a Perl script? Should it start with: #!/usr/bin/perl ? while () { chomp; push @_, $_ } for (reverse @_){ next if /^$/; # ignore blank lines print $_\n; }; Run the above script from the palette or with a key-shortcut to get: -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group.
Re: Flip a Table
At 12:48 PM -0700 7/5/10, Bill Rowe sent email regarding Re: Flip a Table: This can be done in BBEdit with out a separate scratch file as follows: Go to Text-Add/Remove Line Numbers... Add suitable line numbers to the lines you want to reverse the order of with a space between the line number and data you want retained. Then to to Text-Sort Lines... Select Numbers match by value and Reverse sort. Finally go back to Add/Remove Line Numbers... to remove the line numbers previously added. The result will be a reverse order of the data. Just had to format compact first and replace /tr with /tr\r to get each row on its own line, then this add/remove line numbers trick worked fine. Much less hassle than dragging and dropping multiple table rows one at a time! -- You received this message because you are subscribed to the BBEdit Talk discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group.