<?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>My Daily Computer Solutions &#187; parse</title>
	<atom:link href="http://www.dailycomputersolutions.com/blog/index.php/iphone,problems,jobvermeulen,blog,daily,solutions/parse/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailycomputersolutions.com/blog</link>
	<description>All day computer problems with solutions and advice.</description>
	<lastBuildDate>Tue, 20 Dec 2011 13:41:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PERL input and output files</title>
		<link>http://www.dailycomputersolutions.com/blog/index.php/2008/11/17/perl-input-and-output-files/</link>
		<comments>http://www.dailycomputersolutions.com/blog/index.php/2008/11/17/perl-input-and-output-files/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 19:25:25 +0000</pubDate>
		<dc:creator>Job Vermeulen (admin)</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.dailycomputersolutions.com/blog/?p=140</guid>
		<description><![CDATA[To read an input file, edit your data and put it to an output file try this: #! /usr/bin/perl -w use strict; my $file = &#8220;in.csv&#8221;; my $outfile = &#8220;out.csv&#8221;; open(IN, &#8220;&#60;$file&#8221;) or die &#8220;Could not open $file\n&#8221;; open(OUT, &#8220;&#62;$outfile&#8221;) &#8230; <a href="http://www.dailycomputersolutions.com/blog/index.php/2008/11/17/perl-input-and-output-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To read an input file, edit your data and put it to an output file try this:</p>
<p>#! /usr/bin/perl -w</p>
<p>use strict;</p>
<p>my $file = &#8220;in.csv&#8221;;<br />
my $outfile = &#8220;out.csv&#8221;;</p>
<p>open(IN, &#8220;<strong>&lt;</strong>$file&#8221;) or die &#8220;Could not open $file\n&#8221;;<br />
open(OUT, &#8220;<strong>&gt;</strong>$outfile&#8221;) or die &#8220;Could not open $outfile\n&#8221;;</p>
<p>while (&lt;IN&gt;)<br />
{<br />
chomp;<br />
my @line = <strong>split(&#8220;,&#8221;);</strong> # this char is the separation sign.</p>
<p># Your data will now be in a array called line[ ].</p>
<p># Do whatever you want, access the data with the varable $line[FIELDNUMBER]<br />
# Example: $line[3] = &#8216;blablbla&#8217; #edit the 4th value from the input file.</p>
<p>print OUT &#8220;$line[0],$line[3],$line[2]&#8220;\n&#8221;; # write back to output file<br />
}<br />
# close the both files (importend! else the writing will not take place due caching!)<br />
close(IN);<br />
close(OUT);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dailycomputersolutions.com/blog/index.php/2008/11/17/perl-input-and-output-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First steps in Perl parsing CSV from Mamut to Joomla Virtuemart</title>
		<link>http://www.dailycomputersolutions.com/blog/index.php/2008/10/27/first-steps-in-perl/</link>
		<comments>http://www.dailycomputersolutions.com/blog/index.php/2008/10/27/first-steps-in-perl/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 19:25:10 +0000</pubDate>
		<dc:creator>Job Vermeulen (admin)</dc:creator>
				<category><![CDATA[At the office]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[mamut]]></category>
		<category><![CDATA[migrate]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Virtuemart]]></category>
		<category><![CDATA[webshop]]></category>

		<guid isPermaLink="false">http://www.dailycomputersolutions.com/blog/?p=19</guid>
		<description><![CDATA[Today at the office I was asked to help migrating the webshop from Mamut to Joomla Virtuemart. I installed the new webshop, and used the plugin CSVImport to import all data about the products. As allways Mamut was a pain &#8230; <a href="http://www.dailycomputersolutions.com/blog/index.php/2008/10/27/first-steps-in-perl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today at the office I was asked to help migrating the webshop from Mamut to Joomla Virtuemart.</p>
<p>I installed the new webshop, and used the plugin CSVImport to import all data about the products.</p>
<p>As allways Mamut was a pain in the a**, you can export all products BUT:</p>
<ul>
<li>Without all descriptions you perfectly made of the last year</li>
<li>Without all pictures chosen</li>
<li>Without a normal layout in the Categories (messed up with some $$%# charcs)</li>
</ul>
<p>I&#8217;m still working on the pictures and descriptions, found the correct database file but they work with MEMO fields. For some reason the format is not default and cannot be readout easily (keep in touch).</p>
<div>I started to write a C# program to fix all this for me, an hour later my college asked me in what language I was coding. He told me &#8220;Ohh please write this kinda conversion in Perl&#8221;. Until today I never touched Perl, so that was a new experience. He wrote me a very simple program of about 10 lines of code as example and start up.</div>
<div>After some syntax reading I started to write code. I have to admit, 2 hours later the whole job (except images and descriptions) was done..</div>
<div>So take his (and my) advice, if you want to covert or parse a CSV file don&#8217;t use Java, C++, C# or whatever use Perl.</div>
<div>This code can be used to parse the exported product data from Mamut to the format used while importing products in Virtuemart.</div>
<div>To use this, install perl and save the code to a new textfile name FILENAME.pl.</div>
<div><em><strong>Code for Category:</strong></em></div>
<div style="text-align: left;">#! /usr/bin/perl -w</div>
<div style="text-align: left;">
<p>use strict;<br />
# the input file (place in same dir as the script)<br />
my $file = &#8220;in.csv&#8221;;</p>
<p># output file (will be created in the script dir)<br />
my $outfile = &#8220;catout.csv&#8221;;</p>
<p># check for input file<br />
open(IN, &#8220;&lt;$file&#8221;) or die &#8220;Could not open $file\n&#8221;;</p>
<p>#check for permission to write output<br />
open(OUT, &#8220;&gt;$outfile&#8221;) or die &#8220;Could not open $outfile\n&#8221;;</p>
<p># while there are input lines<br />
while (&lt;IN&gt;)<br />
{</p>
<p>chomp;<br />
# split the input line at the comma char (you can change this)<br />
my @line = split(&#8220;,&#8221;);</p>
<p># Replace the Mamut category mess with the \ char<br />
$line[3] =~ s/\%\%/\//g;</p>
<p># print the parsed line to the output file.<br />
# Note: You have to use \ to escape the &#8221; char \&#8221;\&#8221; means an empty entry.<br />
print OUT &#8220;$line[3],\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;managed\&#8221;,\&#8221;flypage.tpl\&#8221;,\&#8221;y\&#8221;,\&#8221;\&#8221;,\n&#8221;;</p>
<p>}</p>
<p># close input file<br />
close(IN);<br />
# close output file<br />
close(OUT);</p>
<p><em><strong>Code for products:</strong></em></p>
<p style="text-align: left;">#! /usr/bin/perl -w</p>
<p>use strict;</p>
<p>my $file = &#8220;in.csv&#8221;;<br />
my $outfile = &#8220;out2.csv&#8221;;</p>
<p>open(IN, &#8220;&lt;$file&#8221;) or die &#8220;Could not open $file\n&#8221;;<br />
open(OUT, &#8220;&gt;$outfile&#8221;) or die &#8220;Could not open $outfile\n&#8221;;</p>
<p>while (&lt;IN&gt;)<br />
{<br />
chomp;<br />
my @line = split(&#8220;,&#8221;);<br />
$line[3] =~ s/\%\%/\//g; # replace the category<br />
print OUT &#8220;$line[0],\&#8221;\&#8221;, $line[3], $line[1],\&#8221;\&#8221;,\&#8221;\&#8221;,$line[11],\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;EUR\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;,\&#8221;Y\&#8221;,\&#8221;N\&#8221;,\&#8221;\&#8221;,\&#8221;\&#8221;\n&#8221;;<br />
}</p>
<p>close(IN);<br />
close(OUT);</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dailycomputersolutions.com/blog/index.php/2008/10/27/first-steps-in-perl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

