<?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[Script to modify data in .csv file]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have only experience in programming VBA in Excel so i’m totally new to this.<br />
I wanna write a script in any language available in Notepad++ that modifies the data in a comma separated .csv file:</p>
<p dir="auto">The script should loop through each row in the file and do the following:</p>
<p dir="auto">For each row in file<br />
If type = “Mobil” and Left(phonenumber, 3) &lt;&gt; “467” Then type = “Fastmobil”<br />
next row</p>
<p dir="auto">File before script:<br />
orgnr,phonenummer,type<br />
5566848271,4670224311,Mobil<br />
5566848271,4670661963,Mobil<br />
5566848271,463041874,Mobil<br />
5566848271,4630337231,Mobil<br />
5566848271,4685602815,Fast</p>
<p dir="auto">File after script:<br />
orgnr,phonenummer,type<br />
5566848271,46702249311,Fastmobil<br />
5566848271,46706612963,Fastmobil<br />
5566848271,4630410874,Mobil<br />
5566848271,46303377231,Mobil<br />
5566848271,4685602815,Fast</p>
<p dir="auto">So, how do I write the script?<br />
And how do I run it?<br />
I suppose if I write in PHP I can run it from cmd?</p>
<p dir="auto">Regards/<br />
Christian</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/15920/script-to-modify-data-in-csv-file</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 21:33:39 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/15920.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Jun 2018 13:08:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Script to modify data in .csv file on Wed, 13 Jun 2018 15:05:53 GMT]]></title><description><![CDATA[<p dir="auto">Thank you peter,</p>
<p dir="auto">That was a great solution! The output example was incorrect, sorry for that…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32989</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32989</guid><dc:creator><![CDATA[Christian Martinsson]]></dc:creator><pubDate>Wed, 13 Jun 2018 15:05:53 GMT</pubDate></item><item><title><![CDATA[Reply to Script to modify data in .csv file on Wed, 13 Jun 2018 14:11:58 GMT]]></title><description><![CDATA[<p dir="auto">You could do it with a script… but that one can be done with a regular expression in the Search and Replace dialog…</p>
<ul>
<li><strong>Find What:</strong> <code>^(\d+),((?!467)\d+),Mobil$</code></li>
<li><strong>Replace With:</strong> <code>$1,$2,Fastmobil</code></li>
<li><strong><code>☑</code> Regular Expression</strong></li>
</ul>
<p dir="auto">Where</p>
<ul>
<li><code>^(\d+)</code> will match all the digits from the start of line to before the first comma, and store them in <code>$1</code></li>
<li><code>(?!467)</code> makes sure it does <em>not</em> match 467 at the beginning of the phonenumber field</li>
<li><code>((?!467)\d+)</code> stores the phone number (not starting with 467) in <code>$2</code></li>
<li><code>,Mobil$</code> makes sure it ends with “,Mobil”</li>
</ul>
<p dir="auto">If it does not match those requirements, no change is made.  If it does match, then it uses the number stored in <code>$1</code>, then a comma, then the number stored in <code>$2</code>, then a comma, then “Fastmobil”.</p>
<p dir="auto">Oh, wait, sorry.  Your VBA psuedocode said to change it if phone number <em>does not</em> start with 467, but your example output changed if it <em>did</em> start with 467.  In that case,</p>
<ul>
<li><strong>Find What:</strong> <code>^(\d+),(467\d+),Mobil$</code></li>
</ul>
<p dir="auto">Please select whichever you need.</p>
<p dir="auto">See the <a href="https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation" rel="nofollow ugc">FAQ</a> for more about Regular Expressions</p>
]]></description><link>https://community.notepad-plus-plus.org/post/32988</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/32988</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 13 Jun 2018 14:11:58 GMT</pubDate></item></channel></rss>