<?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[Ned on Tech]]></title><description><![CDATA[Ned on Tech]]></description><link>https://nedjamta.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Ned on Tech</title><link>https://nedjamta.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 23:43:02 GMT</lastBuildDate><atom:link href="https://nedjamta.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Ran Out of Tokens - Day 2 - awk]]></title><description><![CDATA[It's day 2 without an AI to help me in my IDE. Surprisingly, I feel happy, even a little excited.
I need to use data in a csv file and transform it into a SQL query that manually insert data row by ro]]></description><link>https://nedjamta.hashnode.dev/ran-out-of-tokens-day-2-awk</link><guid isPermaLink="true">https://nedjamta.hashnode.dev/ran-out-of-tokens-day-2-awk</guid><dc:creator><![CDATA[Ned Jamta]]></dc:creator><pubDate>Sat, 13 Jun 2026 04:01:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a2a2f9a9831e41d06dcb422/6cce973e-5bcf-4fe2-8c86-cbc65e2fc59f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It's day 2 without an AI to help me in my IDE. Surprisingly, I feel happy, even a little excited.</p>
<p>I need to use data in a csv file and transform it into a SQL query that manually insert data row by row for a local data seed.</p>
<p>Even without coding copilot, I still need to rely on AI in a browser for a syntax. So I prompted.</p>
<blockquote>
<p>Given a csv file, how can I sed/grep specific columns through terminal?</p>
</blockquote>
<p>I used the known terms <code>sed</code> and <code>grep</code>, hoping it understands my context better.</p>
<p>But, to my surprise, it recommended <code>awk</code>, my new learning today.</p>
<pre><code class="language-plaintext">awk -F, '{print \(1, \)2}' file.csv
</code></pre>
<p>This basic yet powerful command allows to to print the first 2 columns of the CSV file.</p>
<p>In my case, my first column is a <code>productId</code> which is string, and my second column <code>price</code> which is numeric. So I can use <code>printf</code> so that it returns my preferred format.</p>
<pre><code class="language-plaintext">awk -F, {printf("('\''%s'\'', %s),\n", \(1, \)2)} file.csv | tr -d '""'
</code></pre>
<p>I also use <code>tr</code> here to remove double quote that I don't need.</p>
<p>Here is what I got</p>
<pre><code class="language-plaintext">('885100', 99.00),
('885200', 109.00),
...
</code></pre>
<p>And yes, I can pretty much copy and paste this into my SQL script to insert product and price, row by row.</p>
<p>If I had tokens left, I would have prompted <code>given this file.csv, extract barcode and price to create a data seed migration</code>. It has been working fine for a while, until I came to realize that my tokens are limited and that I need to rely less on AI.</p>
<p>If you are not running out of tokens (yet), congratulation. But if one day you do, remember <code>awk</code>.</p>
]]></content:encoded></item><item><title><![CDATA[Ran Out of Tokens - Day 1 - sed command]]></title><description><![CDATA[Ran Out of Tokens is a journey through the days when my monthly AI copilot credits ran out.
Today, I want to write a SQL script to insert a few hundred barcodes as a data seed for local test.
First I ]]></description><link>https://nedjamta.hashnode.dev/ran-out-of-tokens-day-1-sed-command</link><guid isPermaLink="true">https://nedjamta.hashnode.dev/ran-out-of-tokens-day-1-sed-command</guid><category><![CDATA[Linux]]></category><category><![CDATA[AI]]></category><category><![CDATA[sed]]></category><dc:creator><![CDATA[Ned Jamta]]></dc:creator><pubDate>Wed, 10 Jun 2026 11:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a2a2f9a9831e41d06dcb422/6ca15916-3ba6-48f4-bc0a-36ab800836c1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ran Out of Tokens is a journey through the days when my monthly AI copilot credits ran out.</p>
<p>Today, I want to write a SQL script to insert a few hundred barcodes as a data seed for local test.</p>
<p>First I need to some how, extract a list of barcodes from another SQL file that also do insertion, but to another table with a different set of columns</p>
<pre><code class="language-sql">-- old_script.sql
INSERT INTO table_a (...) VALUES ('885100', '000100', ...)
</code></pre>
<p>With AI, I would simply added <code>old_script.sql</code> to an AI copilot and then prompt <code>given this file, create another file that insert the similar barcode to table_b</code></p>
<p>Unfortunately, my company's internal AI credits ran out. And there is a policy against using external / personal AI to read company's code base, as it risks data leakage.</p>
<p>The data scientist version of me might try a Python script to extract the list of barcode, probably with regex, but as I have been observing AI doing their (my) jobs, it often uses faster alternatives - a linux command like <code>sed</code> or <code>grep</code></p>
<p>So through some examples on the internet, and ChatGPT (without letting it read my code), I came up with</p>
<pre><code class="language-shell">sed -n "s/.*('\([^']*\)', '0.*/\1/p" file.sql
</code></pre>
<p>This detects a string between <code>('</code> and <code>', '0)</code> and magically list them out line by line</p>
<pre><code class="language-plaintext">885100
885200
...
</code></pre>
<p>Then I modify the command a bit by adding <code>| sed "s/.*/'&amp;',/</code>, so the output becomes</p>
<pre><code class="language-plaintext">'885100',
'885200',
...
</code></pre>
<p>Now I can simply copy these barcodes from Terminal and then continue my quest writing SQL script which, fortunately, I'm familiar with, and I don't need further assistance from AI.</p>
]]></content:encoded></item></channel></rss>