<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Zeroth! &#187; Hacks</title>
	<atom:link href="http://thezeroth.net/category/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://thezeroth.net</link>
	<description>before the first...</description>
	<lastBuildDate>Sat, 31 Dec 2011 19:51:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to use Qt&#8217;s .pro file variable in C++ code</title>
		<link>http://thezeroth.net/2011/07/28/how-to-use-qts-pro-file-variable-in-c-code/</link>
		<comments>http://thezeroth.net/2011/07/28/how-to-use-qts-pro-file-variable-in-c-code/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 12:00:12 +0000</pubDate>
		<dc:creator>thezeroth</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[qt]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://thezeroth.net/?p=240</guid>
		<description><![CDATA[So today my colleague ask me &#8221; I have a variable VERSION in .pro file (qmake project file) I want to use that variable in my C++ code, How to do that?&#8221; After a little search on Google I figured that we have export project files variable as a macro for C/C++ code and it very easy. As [...]]]></description>
			<content:encoded><![CDATA[<p>So today my colleague ask me &#8221; I have a variable VERSION in  .pro file (qmake project file) I want to use that variable in my C++ code, How to do that?&#8221;</p>
<p>After a little search on Google I figured that we have export project files variable as a macro for C/C++ code and it very easy.</p>
<p>As the per problem we want VERSION variable in C++ code. So in  project file we write</p>
<p><code>DEFINES += VERSION=\\\"$$VERSION\\\"</code></p>
<p>and in C/C++ code just</p>
<p><code>qDebug()&lt;&lt; VERSION ;</code></p>
<p>this is just a awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://thezeroth.net/2011/07/28/how-to-use-qts-pro-file-variable-in-c-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good News About KDE!!</title>
		<link>http://thezeroth.net/2010/12/31/good-news-about-kde/</link>
		<comments>http://thezeroth.net/2010/12/31/good-news-about-kde/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 11:57:56 +0000</pubDate>
		<dc:creator>thezeroth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[kate]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[qt]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kdeindia]]></category>

		<guid isPermaLink="false">http://thezeroth.net/?p=214</guid>
		<description><![CDATA[In my last post I mention about the disappointment I got because of No KDE day at Foss.in/2010. But here&#8217;s the GOOD NEWS instead of KDE day we all (Kde developer&#8217;s team Kde India ) decided to have a KDE conference in India hurry!! . Photo credit Dinesh Sai So we have First Ever KDE conference in India [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://thezeroth.net/2010/12/30/my-first-open-source-conference-presentation/" target="_blank">last post</a> I mention about the disappointment I got because of No KDE day at Foss.in/2010.</p>
<p>But here&#8217;s the GOOD NEWS instead of KDE day we all (Kde developer&#8217;s team Kde India ) decided to have a KDE conference in India hurry!! <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p style="text-align: center;"><a href="http://thezeroth.net/wp-content/uploads/2010/12/team_kdeindia.jpg"><img class="size-full wp-image-215 aligncenter" title="team_kdeindia" src="http://thezeroth.net/wp-content/uploads/2010/12/team_kdeindia.jpg" alt="Team KdeIndia" width="474" height="266" /></a></p>
<h5><span style="font-weight: normal;">Photo credit <a href="http://saidinesh5.wordpress.com/" target="_blank">Dinesh Sai</a></span></h5>
<p><span style="font-weight: normal;"><a href="http://saidinesh5.wordpress.com/" target="_blank"></a></span><span style="font-weight: normal; font-size: 13px;">So we have First Ever KDE conference in India details are as follow:</span></p>
<p>Website : http://conf.kde.in</p>
<p>When:  9 &#8211; 13 March.</p>
<p>Where : R V College Of Engineering,<br />
R V Vidyanikethan Post,<br />
Mysore Road,<br />
Bengaluru – 560004,<br />
Karnataka, India</p>
<p>So lock your calendars, apply for leaves and get prepare for the event!</p>
<p>All are welcome from newbies to Old contributors.</p>
<p>See you there Enjoy <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://thezeroth.net/2010/12/31/good-news-about-kde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Process state check using bash script</title>
		<link>http://thezeroth.net/2010/09/19/process-state-check-using-bash-script/</link>
		<comments>http://thezeroth.net/2010/09/19/process-state-check-using-bash-script/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 20:39:42 +0000</pubDate>
		<dc:creator>thezeroth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://thezeroth.net/?p=188</guid>
		<description><![CDATA[After a long time . well recently I came across a situation where my server application use to crash randomly, so to keep it alive all the time I wrote a small bash scrip, well I know, I have to check my Server application code and fix it but that was the demo time so [...]]]></description>
			<content:encoded><![CDATA[<p>After a long time <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
well recently I came across a situation where my server application use to crash randomly, so to keep it alive all the time I wrote a small bash scrip, well I know, I have to check my Server application code and fix it but that was the demo time so 1st make it work as it is then we will fix the corner cases <img src='http://thezeroth.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .</p>
<p>but bash script was a fun..</p>
<p>This is how my script looks</p>
<p><code><br />
#!/bin/sh</code></p>
<p style="padding-left: 30px;"><code>while true; do</code></p>
<p style="padding-left: 60px;"><code># If process is not running we will get only 1 else 1 + number of instances<br />
check=`ps ax| grep -c TCPServer`<br />
if [ "$check" -lt 2 ]; then</code></p>
<p style="padding-left: 90px;"><code>echo "not running"<br />
# Start the server again<br />
cd ~/TCPServer/<br />
./TCPServer &gt; /dev/null 2&gt;&amp;1 &amp;<br />
else</code><code> echo "running"<br />
</code></p>
<p style="padding-left: 60px;"><code>fi<br />
</code></p>
<p style="padding-left: 30px;"><code>sleep 1m</code></p>
<p style="padding-left: 30px;"><code>done</code></p>
<p style="padding-left: 30px;">
]]></content:encoded>
			<wfw:commentRss>http://thezeroth.net/2010/09/19/process-state-check-using-bash-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Qt for Symbian SDK 4.6.2 on Linux</title>
		<link>http://thezeroth.net/2010/03/20/installing-qt-for-symbian-sdk-4-6-2-on-linux/</link>
		<comments>http://thezeroth.net/2010/03/20/installing-qt-for-symbian-sdk-4-6-2-on-linux/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 06:19:06 +0000</pubDate>
		<dc:creator>thezeroth</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://thezeroth.net/?p=151</guid>
		<description><![CDATA[As we all know now Qt can run on Symbian Phones but there is one problem all SDK&#8217;s and Tool chain of this officially supports windows. So how about people like us(who&#8217;s default OS is Linux) cant we develop for Symbian using Qt? In answer to this question I found many articles/blogpost how to install [...]]]></description>
			<content:encoded><![CDATA[<p>As we all know now Qt can run on Symbian Phones but there is one problem all SDK&#8217;s and Tool chain of this officially supports windows.</p>
<p>So how about people like us(who&#8217;s default OS is Linux) cant we develop for Symbian using Qt?</p>
<p>In answer to this question I found many articles/blogpost how to install Qt for Symbian on Linux but this is the one which work for me <a title="installing-qt-for-symbian-sdk-4-6-2-on-linux" href="http://lizardo.wordpress.com/2010/02/18/installing-qt-for-symbian-sdk-4-6-2-on-linux/" target="_blank">http://lizardo.wordpress.com/2010/02/18/installing-qt-for-symbian-sdk-4-6-2-on-linux/</a> .</p>
<p>I followed this post every thing was perfect except 2 things</p>
<p>1) creating .sis(the Symbian executable) file.</p>
<p>2) creating installer.sis(the Symbian executable installer) file.</p>
<p>and i figured out how to do that too.</p>
<p>I re-witting the basic installation from <a title="installing-qt-for-symbian-sdk-4-6-2-on-linux" href="http://lizardo.wordpress.com/2010/02/18/installing-qt-for-symbian-sdk-4-6-2-on-linux/" target="_blank">http://lizardo.wordpress.com/2010/02/18/installing-qt-for-symbian-sdk-4-6-2-on-linux/</a> . plus my Hacks/Tricks .</p>
<h1><span style="color: #ffffff;">Tool-Chain:</span></h1>
<p>Download all required files to a single directory (e.g. “~/downloads”):</p>
<ul>
<li><a href="http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Platforms/S60_Platform_SDKs/">S60_5th_Edition_SDK_v1_0_en.zip (623MB) or S60-SDK-200634-3.1-Cpp-f.1090b.zip (355MB)</a>: S60 SDK for Symbian OS (be sure to click on the “Download all-in-one S60 SDKs” button for 5th edition, or “Download S60 SDKs for C++” for 3rd edition, FP1)</li>
<li><a href="http://www.forum.nokia.com/Technology_Topics/Development_Platforms/Open_C_and_C++/">s60_open_c_cpp_plug_in_v1_6_en.zip</a> (35MB): Open C/C++ Plug-in</li>
<li><a href="http://get.qt.nokia.com/qt/source/qt-symbian-opensource-4.6.2.exe">qt-symbian-opensource-4.6.2.exe</a> (201MB): Qt for Open Source C++ development on Symbian</li>
<li><a href="http://www.codesourcery.com/sgpp/lite/arm/releases/2005Q1C">gnu-csl-arm-2005Q1C-arm-none-symbianelf-i686-pc-linux-gnu.tar.bz2</a> (11MB): CodeSourcery’s ARM toolchain for Symbian</li>
<li><a href="http://www.martin.st/symbian/gnupoc-package-1.15.tar.gz">gnupoc-package-1.15.tar.gz</a> (6.2MB): tools and patches to run Symbian SDK on Linux</li>
<li><a href="http://franciscoalecrim.com/lizardo/gnupoc_1.15_installer_v2.sh">gnupoc_1.15_installer_v2.sh</a>: Unofficial GnuPoc installer (supports 3.1 and 5.0 SDKs)</li>
<li><a href="http://franciscoalecrim.com/lizardo/qt_for_symbian_4.6.2_linux_installer_v3.sh">qt_for_symbian_4.6.2_linux_installer_v3.sh</a>: Unofficial Qt for Symbian installer for Linux</li>
<li><a title="Nokia Smart Installer" href="http://get.qt.nokia.com/nokiasmartinstaller/" target="_blank">Nokia Smart Installer</a> Which makes it easier to deploy your Qt application to Symbian phones.</li>
</ul>
<p>For building the native tools from gnupoc, you will need:</p>
<ul>
<li>the GCC C/C++ compilers</li>
<li>development files for zlib</li>
<li>development files for openssl</li>
</ul>
<p>On Ubuntu, you can install these using the following command:</p>
<p><code>sudo apt-get install build-essential zlib1g-dev libssl-dev</code></p>
<h1><span style="color: #ffffff;">Installation</span></h1>
<p>First, install GnuPoc + S60 SDK + the Open C/C++ plugin:</p>
<p><code>./gnupoc_1.15_installer_v2.sh \<br />
&lt;download-dir&gt; \<br />
&lt;gnupoc-dir&gt;\<br />
&lt;x.y&gt;</code></p>
<p>Replace &lt;download-dir&gt; with the location of all files downloaded in previous section (e.g. “~/downloads”), &lt;gnupoc-dir&gt; with the destination directory for GnuPoc and the SDK files (e.g. “~/gnupoc”) and &lt;x.y&gt; (Note that this is not the directory) with the SDK version you want to install (e.g. “3.1″ or “5.0″). Note that both directories must have absolute paths.</p>
<p>If installation was successful, you should see an output like:</p>
<p><code>Installation has finished. Before using the GnuPoc SDK, run these commands on the console:</code></p>
<p>export PATH=&lt;gnupoc-dir&gt;/bin:$PATH<br />
export EPOCROOT=&lt;gnupoc-dir&gt;/symbian-sdks/5.0/ # trailing &#8220;/&#8221; is required!</p>
<p>(These commands must be run again every time a new console is opened.)</p>
<p>Run the commands as instructed on the message. Next, install Qt for Symbian:</p>
<p><code>./qt_for_symbian_4.6.2_linux_installer_v3.sh \<br />
&lt;download-dir&gt; \<br />
&lt;qt-s60-dir&gt;</code></p>
<p>Replace &lt;download-dir&gt; with the location of all files downloaded in previous section (e.g. “~/downloads”), and &lt;qt-s60-dir&gt; with the destination directory for the Qt files (e.g. “~/gnupoc/qt-4.6.2″). Note that both directories must have absolute paths.</p>
<p>If installation was successful, you should see an output like:<br />
<code>Installation has finished. Before using the Qt for Symbian SDK, run this command on the console:</code></p>
<p>export PATH=&lt;qt-s60-dir&gt;/bin:$PATH<br />
unset QMAKESPEC    # make sure there is no QMAKESPEC variable set</p>
<p>(This command must be run again every time a new console is opened.)</p>
<p>Before using Qt for Symbian, you should run the command as instructed on the message above.</p>
<h1><span style="color: #ffffff;">Usage example</span></h1>
<p>Install Nokia Smart Installer :</p>
<ol>
<li>Unzip Nokia Smart Installer  on top of your installed Qt for Symbian folder <code>in &lt;qt-s60-dir&gt;</code></li>
</ol>
<p>To test the installation, I will describe how to build the “colliding mice” example.</p>
<ol>
<li>cd into the example source:</li>
<p><code>cd &lt;qt-s60-dir&gt;/examples/graphicsview/collidingmice/</code></p>
<li>Now build the example and generate the SIS file</li>
<p><code>qmake<br />
make debug-gcce<br />
make sis<br />
make installer_sis<br />
</code></ol>
<h2><span style="color: #ffffff;">Chnages/Hack/Tricks</span></h2>
<p>You will notice that when  you do <code> make installer_sis</code><br />
there is some error related to &#8220;createpackage.bat&#8221; file this is batch file what we have to do is open</p>
<p><code>Makefile</code></p>
<p>search for <code>ok_installer_sis:</code></p>
<p>and change <code>createpackage.bat to createpackage.sh</code></p>
<p>createpackage.sh is already there just that its not getting reflected in Makefile .</p>
<p>and now if you do <code>make installer_sis</code> you will get <code>collidingmice_installer.sis</code></p>
<p>I have also created one bash function as follow:<br />
<code><br />
function qtsis {<br />
export PATH=&lt;gnupoc-dir&gt;/bin:$PATH<br />
export EPOCROOT=&lt;gnupoc-dir&gt;/symbian-sdks/5.0/ # trailing "/" is required!<br />
export PATH=&lt;qt-s60-dir&gt;/bin:$PATH<br />
unset QMAKESPEC    # make sure there is no QMAKESPEC variable set<br />
}<br />
</code><br />
Add this function in your .bashrc file with proper path which you get after installation.</p>
<p>and do <code>source ~/.bashrc</code></p>
<p>now when ever you want to compile your qt code for Symbian 1st execute qtsis command on your terminal  then other qt commands <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A few notes:</p>
<ul>
<li>Make sure Qt is installed on the device before installing Qt applications. The easiest way to install it is to copy the “qt_installer.sis” package found under &lt;qt-s60-dir&gt; over bluetooth and open the received message to begin the installation.</li>
<li>Only the “debug-gcce” (if you are using the GCCE toolchain AKA “CodeSourcery toolchain”) or “debug-armv5″ (if you are using RVCT) will work, because the current Qt releases only ship debug versions of the libraries</li>
</ul>
<p>enjoy <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://thezeroth.net/2010/03/20/installing-qt-for-symbian-sdk-4-6-2-on-linux/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>My 1st Open-Source contribution</title>
		<link>http://thezeroth.net/2010/01/12/my-1st-open-source-contribution/</link>
		<comments>http://thezeroth.net/2010/01/12/my-1st-open-source-contribution/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 17:35:13 +0000</pubDate>
		<dc:creator>thezeroth</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[kate]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[wish-list]]></category>

		<guid isPermaLink="false">http://thezeroth.wordpress.com/?p=79</guid>
		<description><![CDATA[Long time since I made a blog post &#8230; My new year started with a bang .. completing one item from my own wish list i.e contribute to a Open-Source project. I have started contributing to KDE Kate. My 1st patch accepted for BUG No. 184055 which is now in kde 4.4 . Hurray &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Long time since I made a blog post &#8230; My new year started with a bang .. completing one item from my own wish list i.e contribute to a <a title="Open-Source" href="http://en.wikipedia.org/wiki/Open_source" target="_blank">Open-Source</a> project.</p>
<p>I have started contributing to KDE Kate. My 1st patch accepted for BUG No. <a title="Bug" href="https://bugs.kde.org/show_bug.cgi?id=184055" target="_blank">184055</a> which is now in kde 4.4 <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Hurray &#8230;</p>
<p>About the fix:<br />
Problem : Previously in Kate&#8217;s document view  the last added file was not getting sorted as per the given sorting option.<br />
Solution: Whenever user open the file call the document views sorting.</p>
<p>* for more details  here is the <a title="Bug" href="https://bugs.kde.org/show_bug.cgi?id=184055" target="_blank">bug description</a> .</p>
<p>To download patch <a title="patch" href="http://thezeroth.net/patches/kate-Bug-184055_v3.patch" target="_blank">click here</a>.</p>
<p>Though it was really small bug fix it was really a good learning experience. I will try to be consistent with contributing to <a title="KDE" href="http://www.kde.org" target="_blank">KDE</a> <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>All credit goes to <a title="Pradeepto" href="http://pradeepto.livejournal.com/" target="_blank">Pradeepto</a> and <a title="Prashanth" href="http://prashanthudupa.livejournal.com" target="_blank">Prashanth</a> for encouraging and guiding me <img src='http://thezeroth.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Thanks guys.</p>
]]></content:encoded>
			<wfw:commentRss>http://thezeroth.net/2010/01/12/my-1st-open-source-contribution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python CSV Hack!</title>
		<link>http://thezeroth.net/2009/12/09/python-csv-hack/</link>
		<comments>http://thezeroth.net/2009/12/09/python-csv-hack/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 17:29:19 +0000</pubDate>
		<dc:creator>thezeroth</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Broadband]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Reliance]]></category>

		<guid isPermaLink="false">http://thezeroth.wordpress.com/?p=64</guid>
		<description><![CDATA[This is just a simple hack I did today morning. This is to calculate my total internet data usages. From my ISP Reliance Netconnect Broadband + I get one CSV file with all the details, and to view this I don&#8217;t have any spreadsheet viewer kinda thing installed on my system, so how to calculate the [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a simple hack I did today morning.</p>
<p>This is to calculate my total internet data usages.</p>
<p>From my ISP <a title="Reliance Com" href="http://www.rcom.co.in/" target="_blank">Reliance Netconnect Broadband +</a> I get one CSV file with all the details, and to view this I don&#8217;t have any spreadsheet viewer kinda thing installed on my system, so how to calculate the usages?</p>
<p>I wrote small python script to do so, this is about it how it works.</p>
<p>contents of CSV file looks something like this :<br />
<code><br />
Date Of Access,Time Of Access,Session Duration,Data Upload(KBs),Data Download(KBs),Total Data Transferred(KBs)<br />
22-10-2009, 07:36:58,2623,1060.50390625,7934.458984375,8994.962890625<br />
22-10-2009, 19:47:34,13675,22826.49609375,344230.265625,367056.76171875<br />
22-10-2009, 23:35:29,229,24.2666015625,33.56640625,57.8330078125<br />
22-10-2009, 23:39:18,13792,838.701171875,11057.255859375,11895.95703125<br />
23-10-2009, 03:32:53,14839,18841.23046875,104978.8837890625,123820.1142578125<br />
23-10-2009, 20:47:20,292,117.1015625,647.9287109375,765.0302734375<br />
23-10-2009, 20:52:12,233,226.669921875,2429.98828125,2656.658203125<br />
23-10-2009, 03:32:49,4,0,0,0<br />
23-10-2009, 20:56:08,22657,57322.56640625,939251.0869140625,996573.6533203125<br />
24-10-2009, 03:13:45,1399,145.619140625,287.9228515625,433.5419921875<br />
24-10-2009, 03:37:03,4745,199.060546875,289.611328125,488.671875<br />
24-10-2009, 19:40:46,3172,799.1708984375,5288.591796875,6087.7626953125</code></p>
<p>Basically divided into 6 Fields ie.<br />
Date Of Access  | Time Of Access | Session Duration  | Data Upload(KBs) | Data Download(KBs) | Total Data Transferred(KBs)<br />
separated by &#8220;,&#8221; (comma) .</p>
<p>Here my required field is Total Data Transferred(KBs), thats the last field.</p>
<p>means I need to add <strong>last field of each row</strong>.</p>
<p>the python scrip for the same is:<br />
<code><span style="color: #808080;"># Open file</span><br />
f = open("tel.csv") </code></p>
<p><code><span style="color: #808080;"># Read all lines in list called lines</span><br />
lines = f.readlines()</code></p>
<p><code><span style="color: #808080;"># Initialize variable to store the total</span><br />
total = 0.0 </code></p>
<p><code><span style="color: #808080;">""" Remove the 1st line from the lines list as<br />
it's the header which we don't require"""</span><br />
lines.pop(0)<br />
</code></p>
<p><code>for i in lines:</code></p>
<p style="padding-left: 30px;"><code><span style="color: #808080;">""" Split each line on ","(comma)<br />
so that you will get all the 6 fields for that line as list"""</span><br />
i = i.split(",")</code></p>
<p style="padding-left: 30px;"><code><span style="color: #808080;">""" Take the last value, convert it to float<br />
and add it to the total variable"""</span><br />
total += float(i[-1])</code></p>
<p><code><span style="color: #808080;"># Print the total in Kb</span><br />
print "total data uses in Kb: " + total<br />
<span style="color: #808080;"> # Print the total in Mb</span><br />
print "total data uses in Mb: " + total/1024<br />
<span style="color: #808080;"> # Print the total in Gb</span><br />
print "total data uses in Gb: " + (total/1024)/1024<br />
</code></p>
<p>Happy Hacking !!</p>
]]></content:encoded>
			<wfw:commentRss>http://thezeroth.net/2009/12/09/python-csv-hack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

