<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[regex to conditionally delete unnecessary lines in .csv files?]]></title><description><![CDATA[<p dir="auto">Can I use regex expression and replace function to delete lines that have 0 in the fourth data field of a .csv file?</p>
<p dir="auto">Before<br />
20180829014727,40.393018,-117.974365,14.54421,163.1<br />
20180829014740,40.590137,-117.952637,12.82776,162.3<br />
20180829014754,40.187256,-117.505029,13.20208,162.5<br />
20180829014832,40.372559,-117.538574,41.76501,162.5<br />
20180829014836,40.584375,-117.960938,0,162.8<br />
20180829014840,40.152100,-117.909180,0,162.7<br />
20180829014845,40.346338,-117.683301,0,162.7</p>
<p dir="auto">After<br />
20180829014727,40.393018,-117.974365,14.54421,163.1<br />
20180829014740,40.590137,-117.952637,12.82776,162.3<br />
20180829014754,40.187256,-117.505029,13.20208,162.5<br />
20180829014832,40.372559,-117.538574,41.76501,162.5</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16723/regex-to-conditionally-delete-unnecessary-lines-in-csv-files</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 05:03:32 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16723.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Nov 2018 18:05:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to regex to conditionally delete unnecessary lines in .csv files? on Fri, 30 Nov 2018 18:58:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/brandon-tibbitts" aria-label="Profile: Brandon-Tibbitts">@<bdi>Brandon-Tibbitts</bdi></a></p>
<p dir="auto">You can’t do arithmetic in this (regex) manner.  You’re going to need a programming language for that, or perhaps, since you appear to have .csv files, pulling the data into Excel to do the math would work.  Good luck.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37029</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37029</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Fri, 30 Nov 2018 18:58:21 GMT</pubDate></item><item><title><![CDATA[Reply to regex to conditionally delete unnecessary lines in .csv files? on Fri, 30 Nov 2018 18:20:48 GMT]]></title><description><![CDATA[<p dir="auto">Thank you Terry,</p>
<p dir="auto">That helps me out a ton.</p>
<p dir="auto">Is there also a way to do arithmetic on that same field(after the zero values/lines removed), so for example if I wanted to add to or multiply the  fourth field value in every line across a file</p>
<p dir="auto">I suspect the first part of the regex would be the same ^([^,]+,){3}0,.  but rather with a filter to recognize any value in that field instead of the 0, then a replace function similar but to replace it with a modified value</p>
<p dir="auto">Or should I post a new topic to cover that one separately?</p>
<p dir="auto">Brandon</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37024</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37024</guid><dc:creator><![CDATA[Brandon Tibbitts]]></dc:creator><pubDate>Fri, 30 Nov 2018 18:20:48 GMT</pubDate></item><item><title><![CDATA[Reply to regex to conditionally delete unnecessary lines in .csv files? on Thu, 29 Nov 2018 18:50:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/brandon-tibbitts" aria-label="Profile: Brandon-Tibbitts">@<bdi>Brandon-Tibbitts</bdi></a><br />
I just realised that although my regex works well on your example there is an instance where it won’t. If the 4th field contains something like <code>0.76</code> then my regex will still pick it. The correct regex is:<br />
<code>^([^,]+,){3}0,.+\R*</code><br />
Note the addition of a comma after the zero.</p>
<p dir="auto">Sorry about that.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36977</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36977</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 29 Nov 2018 18:50:54 GMT</pubDate></item><item><title><![CDATA[Reply to regex to conditionally delete unnecessary lines in .csv files? on Thu, 29 Nov 2018 18:37:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/brandon-tibbitts" aria-label="Profile: Brandon-Tibbitts">@<bdi>Brandon-Tibbitts</bdi></a><br />
Certainly and quite simply. The following regex will filter out those lines.<br />
Find What:<code>^([^,]+,){3}0.+\R*</code><br />
Replace With:<code>empty field</code>  &lt;—nothing in this field.</p>
<p dir="auto">Have search mode as “regular expression” and wraparound ticked.<br />
As a brief explanation:<br />
<code>[^,]</code> means any character that is NOT a comma<br />
<code>([^,]+,)</code> means any number of non-commas followed by a comma.<br />
<code>{3}</code> means three sets of the expression preceding (inside brackets).<br />
<code>0.+\R*</code> means a zero followed by as many characters as possible followed by the carriage return line if it exists (this caters for the last line).</p>
<p dir="auto">As the replace with field is empty is just removes that line. When complete check the very last line as it will likely be blank, so you may need to remove that.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36974</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36974</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 29 Nov 2018 18:37:19 GMT</pubDate></item></channel></rss>