<?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>Tim Thorp Training &#38; Consulting &#187; excel</title>
	<atom:link href="http://www.timthorp.com/tag/excel/feed" rel="self" type="application/rss+xml" />
	<link>http://www.timthorp.com</link>
	<description>technology made simple.</description>
	<lastBuildDate>Mon, 19 Oct 2009 14:45:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Splitting LASTNAME,FIRSTNAME columns in Excel</title>
		<link>http://www.timthorp.com/tech-tips/splitting-lastnamefirstname-columns-in-excel</link>
		<comments>http://www.timthorp.com/tech-tips/splitting-lastnamefirstname-columns-in-excel#comments</comments>
		<pubDate>Wed, 14 May 2008 14:10:38 +0000</pubDate>
		<dc:creator>Tim Thorp</dc:creator>
				<category><![CDATA[tech tips]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[formula]]></category>
		<category><![CDATA[names]]></category>
		<category><![CDATA[split]]></category>

		<guid isPermaLink="false">http://www.timthorp.com/uncategorized/splitting-lastnamefirstname-columns-in-excel</guid>
		<description><![CDATA[Too often, office workers have to manipulate improperly structured data that comes from mega-systems. For example, if a person wanted to do a mail merge intro line, stating, &#8220;Dear &#60;firstname&#62;&#8221; but the name field held LASTNAME,FIRSTNAME, they would have a hard time, but here’s a way to handle it using an excel formula that pulls [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Too often, office workers have to manipulate improperly structured data that comes from mega-systems. For example, if a person wanted to do a mail merge intro line, stating, &#8220;Dear &lt;firstname&gt;&#8221; but the name field held LASTNAME,FIRSTNAME, they would have a hard time, but here’s a way to handle it using an excel formula that pulls it apart and displays the correct name in title case. I haven’t really tested it with special names including extra things like sir or esquire, but it works pretty good for most names.</p>
<p class="MsoNormal">Assuming cell A1 holds a name like THORP,TIMOTHY – this formula will result in Timothy Thorp</p>

<div class="wp_codebox"><table><tr id="p144"><td class="code" id="p14code4"><pre class="excel" style="font-family:monospace;">=PROPER(CONCATENATE(TRIM(RIGHT(A1, LEN(A1)- FIND(&quot;,&quot;,A1,1))), &quot; &quot;, LEFT(A1,FIND(&quot;,&quot;,A1,1)-1)))</pre></td></tr></table></div>

<p class="MsoNormal">Explanation of each function in the order that it is processed:</p>
<p class="MsoNormal">LEN() counts the number of characters in the name (in this example, 13)</p>
<p class="MsoNormal">FIND() returns the character position of the comma (in this example, 6)</p>
<p class="MsoNormal">RIGHT() returns the calculated number of characters to the right of the comma (in this example, chars 7-13 or TIMOTHY)</p>
<p class="MsoNormal">LEFT() returns all of the characters from the beginning of the name up to the comma (in this example, characters 1-5 or THORP)</p>
<p class="MsoNormal">TRIM() removes extra blank spaces around the comma in case they are present</p>
<p class="MsoNormal">CONCATENATE() squishes the first and last name into one column together</p>
<p class="MsoNormal">PROPER() puts the name in title case (first letter of each word capitalized)</p>
<p class="MsoNormal">From there, you can use the fill handle to copy the formula down the column and Excel Text to Columns and/or paste special to separate things out as you need.</p>
<p class="MsoNormal">To get the first name by itself :</p>

<div class="wp_codebox"><table><tr id="p145"><td class="code" id="p14code5"><pre class="excel" style="font-family:monospace;">=PROPER(TRIM(RIGHT(A1, LEN(A1)- FIND(&quot;,&quot;,A1,1))))</pre></td></tr></table></div>

<p class="MsoNormal">To get the last name by itself:</p>

<div class="wp_codebox"><table><tr id="p146"><td class="code" id="p14code6"><pre class="excel" style="font-family:monospace;">=PROPER(LEFT(A1,FIND(&quot;,&quot;,A1,1)-1))</pre></td></tr></table></div>

<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://www.timthorp.com/tech-tips/splitting-lastnamefirstname-columns-in-excel/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Export data from MySQL to CSV using PHP</title>
		<link>http://www.timthorp.com/webdev/export-as-csv</link>
		<comments>http://www.timthorp.com/webdev/export-as-csv#comments</comments>
		<pubDate>Thu, 20 Mar 2008 13:00:24 +0000</pubDate>
		<dc:creator>Tim Thorp</dc:creator>
				<category><![CDATA[webdev]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.timthorp.com/webdev/export-as-csv</guid>
		<description><![CDATA[In a recent project, we were collecting registrations for an event using a PHP web form and a MySQL database. The office worker wanted to download all of the collected data in an excel file. In a subsequent meeting with another office worker, the idea of easily downloading the collected data into excel was very [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project, we were collecting registrations for an event using a PHP web form and a MySQL database. The office worker wanted to download all of the collected data in an excel file. In a subsequent meeting with another office worker, the idea of easily downloading the collected data into excel was very convenient for performing mail merges and other administrative tasks, so I tried to make one &#8220;csvdump.php&#8221; file which met many needs.</p>

<div class="wp_codebox"><table><tr id="p98"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p9code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$tbl</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tbl'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//get the table to export from the parameter in the URL</span>
<span style="color: #000088;">$cur</span><span style="color: #339933;">=</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m-j-Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//construct today's date </span>
<span style="color: #000088;">$filename</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;basename_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cur</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.csv&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//construct the default filename </span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: text/csv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: inline; filename=<span style="color: #006699; font-weight: bold;">$filename</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connect.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT * FROM <span style="color: #006699; font-weight: bold;">$tbl</span>;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//loop through field names and put them in the first row, separated by commas</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_field</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$field-&gt;name</span>,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//put a line break after the first row</span>
<span style="color: #666666; font-style: italic;">//loop through records, separating them with commas</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
                <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fields</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                                <span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$row</span>[<span style="color: #006699; font-weight: bold;">$field</span>],&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//line break after each row</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.timthorp.com/webdev/export-as-csv/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
