{"id":22596,"date":"2019-04-30T01:00:24","date_gmt":"2019-04-30T00:00:24","guid":{"rendered":"https:\/\/jurnsearch.wordpress.com\/?p=22596"},"modified":"2019-04-30T01:00:24","modified_gmt":"2019-04-30T00:00:24","slug":"how-to-remove-every-nth-line-in-list","status":"publish","type":"post","link":"https:\/\/jurn.link\/jurnsearch\/index.php\/2019\/04\/30\/how-to-remove-every-nth-line-in-list\/","title":{"rendered":"How to remove every nth line in a list"},"content":{"rendered":"<p><strong>How to remove every nth line in a list.  The list is made up of repeating four-line blocks of text.<\/strong><\/p>\n<p><strong>The situation:<\/strong><\/p>\n<p>You have a long and mostly cleaned text list that looks like this&#8230;<\/p>\n<p>Random article title<br \/>\nRandom author name<br \/>\n<em>Gibbery wibble<\/em><br \/>\nRandom journal title<\/p>\n<p>Random article title<br \/>\nRandom author name<br \/>\n<em>Gibbery wibble<\/em><br \/>\nRandom journal title<\/p>\n<p>Random article title<br \/>\nRandom author name<br \/>\n<em>Gibbery wibble<\/em><br \/>\nRandom journal title<\/p>\n<p>&#8230; and you of course wish to delete all the unwanted <em>Gibbery wibble<\/em> lines.  All the <em>Gibbery wibble<\/em> text is different.  Indeed, there&#8217;s no keyword or repeating element in each four-line data block for a search-replace operation to the grab onto.  The only repeating element is the blank line that separates each data block of four lines.<\/p>\n<p>So far as I can see, after very extensive searching, there&#8217;s as yet no way to deal with this in Notepad++, even with plugins and Python scripts.<\/p>\n<p><strong>The slower solution:<\/strong><\/p>\n<p>The more flexible but longer solution is Excel. However, the latest version of Notepad++ (not the older, 32-bit version) will let you quickly take the first and vital step.  You first delete the blank lines with&#8230;<\/p>\n<p>Edit | Line Operations | Remove Empty Line<\/p>\n<p>It&#8217;s far easier to delete blanks in a long list in Notepad++, rather than wrestling with <a href=\"https:\/\/jurn.link\/jurnsearch\/2013\/12\/28\/excel-are-those-blank-cells-really-empty-how-to-scrub-them-quickly-then-fill-them-with-text\/\">complex ten-step workflows<\/a> in Excel, just to do such a simple thing.<\/p>\n<p>Then you copy-paste the list into a new Excel sheet.  You then add <a href=\"https:\/\/jurn.link\/jurnsearch\/2019\/04\/macros.pdf\">these two Excel macros<\/a> and run the first. Both run fine in Excel 2007. The first splits the column into chunks of 4 (if you have three lines per block, change all the 4s in the macro to 3s, if six lines then change to 6s, and so on). Each chunk is placed into a new column on the same sheet. <\/p>\n<p>You can then delete the offending <em>Gibbery wibble<\/em> row, which will run uniformly across the spreadsheet.  In this example, it all runs across row 3.<\/p>\n<p>The second macro is then run and this recombines all the columns back into a long list, and places the recombined list onto a new sheet.<\/p>\n<p>The free <a href=\"https:\/\/asap-utilities.com\/\">ASAP Utilities<\/a> for Excel <a href=\"https:\/\/jurn.link\/jurnsearch\/2015\/11\/24\/use-ms-excel-2007-to-split-a-long-column-list-into-smaller-chunks\/\">can then &#8216;chunk&#8217; this list back into blocks of four<\/a>, enabling you to add a blank line between each block.  Optionally, you can add the HTML tag for a horizontal rule.<\/p>\n<p>The same core method can be used to re-sort the lines each block, or to add numbering to each line as: | 1. 2. 3. 4. | 1. 2. 3. 4. |  These operations are something Notepad++ can&#8217;t yet do.<\/p>\n<p><strong>The quicker solution:<\/strong><\/p>\n<p>If you need a quicker option, and don&#8217;t need to re-sort the lines in each data block in Excel, then try the Windows freeware <a href=\"https:\/\/www.portablefreeware.com\/index.php?id=2229\">List Numberer<\/a>. As you can see below, once you&#8217;ve used this utility to run a simple operation, then a regex search back in Notepad++ (<strong>.*line3.*<\/strong> \u2014 used in Replace | Replace All) will clear all the unwanted lines.<\/p>\n<p><a href=\"https:\/\/jurn.link\/jurnsearch\/2019\/04\/linedel.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jurn.link\/jurnsearch\/2019\/04\/linedel.jpg?w=529\" alt=\"\" width=\"529\" height=\"384\" class=\"alignnone size-large wp-image-22638\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to remove every nth line in a list. The list is made up of repeating four-line blocks of text. &hellip;<\/p>\n<p><a href=\"https:\/\/jurn.link\/jurnsearch\/index.php\/2019\/04\/30\/how-to-remove-every-nth-line-in-list\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-22596","post","type-post","status-publish","format-standard","hentry","category-jurn-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/posts\/22596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/comments?post=22596"}],"version-history":[{"count":0,"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/posts\/22596\/revisions"}],"wp:attachment":[{"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/media?parent=22596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/categories?post=22596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jurn.link\/jurnsearch\/index.php\/wp-json\/wp\/v2\/tags?post=22596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}