<?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>Algorithm-Forge &#187; Preprocessing</title>
	<atom:link href="http://www.algorithm-forge.com/techblog/tag/preprocessing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.algorithm-forge.com/techblog</link>
	<description>Java, R, Statistics, Algorithms and other stuff</description>
	<lastBuildDate>Sun, 18 Jul 2010 16:53:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>OpenOffice advanced fill down</title>
		<link>http://www.algorithm-forge.com/techblog/2009/08/openoffice-advanced-fill-down/</link>
		<comments>http://www.algorithm-forge.com/techblog/2009/08/openoffice-advanced-fill-down/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 21:30:12 +0000</pubDate>
		<dc:creator>Kornelius Rohmeyer</dc:creator>
				<category><![CDATA[OpenOffice]]></category>
		<category><![CDATA[Preprocessing]]></category>

		<guid isPermaLink="false">http://www.algorithm-forge.com/techblog/?p=29</guid>
		<description><![CDATA[When people come to me for statistical advise, they often bring Excel files containing data like the following, where values are only written down when they change. But often it is required for further analysis that each row is completely &#8230; <a href="http://www.algorithm-forge.com/techblog/2009/08/openoffice-advanced-fill-down/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When people come to me for statistical advise, they often bring Excel files containing data like the following, where values are only written down when they change. But often it is required for further analysis that each row is completely filled with the correct values. There is a basic &#8220;<em>fill down</em>&#8221; option in OpenOffice (<tt>CTRL+D</tt>), but up to my knowledge there is unfortunately no extension for this case.</p>
<p align="center"><img class="alignnone size-full wp-image-31" title="filldown" src="http://www.algorithm-forge.com/techblog/wp-content/uploads/2009/07/filldown.gif" alt="filldown" width="351" height="348" /></p>
<p>Years ago I wrote the following lines in Visual Basic for a small company I was visiting that even employed a student assistant for filling out these missing values in enormous automatically generated Excel files (I did this in just a few minutes and of course free of charge, that&#8217;s why it is so basic &#8211; I just couldn&#8217;t see people doing such dreary tasks):</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">Sub</span> MakroAdvancedFillDown()<br />
&nbsp; <span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> cell <span style="color: #000080;">In</span> Range(<span style="color: #800000;">&quot;h1:h13215&quot;</span>) <br />
&nbsp; &nbsp; <span style="color: #000080;">If</span> cell.Value = <span style="color: #800000;">&quot; &quot;</span> <span style="color: #000080;">Or</span> cell.Value = <span style="color: #800000;">&quot;&quot;</span> <span style="color: #000080;">Then</span> <br />
&nbsp; &nbsp; &nbsp; cell.Value = old <br />
&nbsp; &nbsp; <span style="color: #000080;">End</span> <span style="color: #000080;">If</span> <br />
&nbsp; &nbsp; old = cell.Value <br />
&nbsp; <span style="color: #000080;">Next</span> cell <br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></div></div>
<p>And given that last week someone with a really large table with the same problem came into my office I took an hour to learn StarOffice Basic and to write the following Macro:</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">SUB</span> AdvancedFillDown<br />
&nbsp; oSel = ThisComponent.getCurrentSelection()<br />
&nbsp; oAdr = oSel.rangeAddress<br />
&nbsp; oSheet = ThisComponent.CurrentController.ActiveSheet &nbsp; <br />
&nbsp; <span style="color: #000080;">IF</span> <span style="color: #000080;">NOT</span> oSel.supportsService(<span style="color: #800000;">&quot;com.sun.star.sheet.SheetCellRange&quot;</span>) <span style="color: #000080;">then</span><br />
&nbsp; &nbsp; &nbsp; MsgBox <span style="color: #800000;">&quot;Error: Please select some cells for this makro.&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000080;">EXIT</span> <span style="color: #000080;">SUB</span><br />
&nbsp; <span style="color: #000080;">END</span> <span style="color: #000080;">IF</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; <span style="color: #000080;">FOR</span> j = oAdr.startColumn <span style="color: #000080;">TO</span> oAdr.EndColumn<br />
&nbsp; &nbsp; <span style="color: #000080;">FOR</span> i = oAdr.startRow <span style="color: #000080;">TO</span> oAdr.EndRow<br />
&nbsp; &nbsp; &nbsp; oCell=oSheet.getCellByPosition(j,i)<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000080;">IF</span> oCell.<span style="color: #000080;">string</span> = <span style="color: #800000;">&quot;&quot;</span> <span style="color: #000080;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oSource = oSheet.getCellRangeByPosition(j,i-1,j,i-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; oSourceAdr = oSource.getRangeAddress<br />
&nbsp; &nbsp; &nbsp; &nbsp; oSheet.copyRange(oCell.getCellAddress,oSourceAdr)<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000080;">END</span> <span style="color: #000080;">IF</span><br />
&nbsp; &nbsp; <span style="color: #000080;">NEXT</span><br />
&nbsp; <span style="color: #000080;">NEXT</span><br />
<span style="color: #000080;">END</span> <span style="color: #000080;">SUB</span></div></div>
<p>Now I can deal with this problem with just one click.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.algorithm-forge.com/techblog/2009/08/openoffice-advanced-fill-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
