<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PHP Script: Convert Excel or tab-delimited file to html table</title>
	<atom:link href="http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/</link>
	<description>Say 'no' to styrofoam.</description>
	<lastBuildDate>Thu, 11 Aug 2011 20:07:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: james</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17844</link>
		<dc:creator>james</dc:creator>
		<pubDate>Tue, 05 Aug 2008 13:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17844</guid>
		<description>good stuff!  I&#039;ll scrap mine and put your rewrite into the original post so people will find this first, as it has some clear improvements.  I think I&#039;ll also make the file name a parameter to really make the function flexible.  give me a few days to get to that.</description>
		<content:encoded><![CDATA[<p>good stuff!  I&#8217;ll scrap mine and put your rewrite into the original post so people will find this first, as it has some clear improvements.  I think I&#8217;ll also make the file name a parameter to really make the function flexible.  give me a few days to get to that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Y.T.</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17830</link>
		<dc:creator>Y.T.</dc:creator>
		<pubDate>Tue, 05 Aug 2008 04:24:33 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17830</guid>
		<description>James, I&#039;ll post the version that I&#039;ve settled with, which I consider to be a slightly improved version than the one I posted before (no extra blank row at the end of the table). I think the code can be better written with the use of css. 

/Y.T.

&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;
&lt;?php

    function tabs_to_table($input) {
       //define replacement constants
       define(&#039;TAB_REPLACEMENT&#039;, &quot;&quot;);
       define(&#039;NEWLINE_REPLACEMENT&#039;, &quot;\n&quot;);
       define(&#039;ROW_BEGIN&#039;, &quot;&quot;);
       define(&#039;TABLE_BEGIN&#039;, &quot;\n&quot;);
       define(&#039;TABLE_END&#039;, &quot;\n&quot;);

       //replace all tabs with end-cell, begin-cell
       $input = preg_replace  (&quot;/\t/&quot;  , TAB_REPLACEMENT  , $input);
       //split the list on linebreaks
       $rows = preg_split  (&quot;/\r\n/&quot;  , $input);

       //replace all linebreaks with end-row
       $output = &quot;&quot;;
       foreach ($rows as $index =&gt; $row) {
           if (strlen($row) &gt; 0) {
               $output .= ROW_BEGIN . $row . NEWLINE_REPLACEMENT;
           }
       }

       //build table
       $input = TABLE_BEGIN . $output . TABLE_END;

       return $input;
    }

    // Get Tab delimited text from file
    $filename = &quot;Tab_delimited_file.txt&quot;;
    $handle = fopen($filename, &quot;r&quot;);
    $contents = fread($handle, filesize($filename));
    fclose($handle);

    // Start building the HTML file
    echo &quot;\n&quot;;
    echo &quot;Tab delimited Text to HTML Table\n&quot;;
    echo &quot;\n&quot;;
    print(tabs_to_table($contents));
    echo &quot;\n&quot;;
    echo &quot;\n&quot;;
?&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>James, I&#8217;ll post the version that I&#8217;ve settled with, which I consider to be a slightly improved version than the one I posted before (no extra blank row at the end of the table). I think the code can be better written with the use of css. </p>
<p>/Y.T.</p>
<pre name="code" class="php">
&lt;?php

    function tabs_to_table($input) {
       //define replacement constants
       define('TAB_REPLACEMENT', "");
       define('NEWLINE_REPLACEMENT', "\n");
       define('ROW_BEGIN', "");
       define('TABLE_BEGIN', "\n");
       define('TABLE_END', "\n");

       //replace all tabs with end-cell, begin-cell
       $input = preg_replace  ("/\t/"  , TAB_REPLACEMENT  , $input);
       //split the list on linebreaks
       $rows = preg_split  ("/\r\n/"  , $input);

       //replace all linebreaks with end-row
       $output = "";
       foreach ($rows as $index =&gt; $row) {
           if (strlen($row) &gt; 0) {
               $output .= ROW_BEGIN . $row . NEWLINE_REPLACEMENT;
           }
       }

       //build table
       $input = TABLE_BEGIN . $output . TABLE_END;

       return $input;
    }

    // Get Tab delimited text from file
    $filename = "Tab_delimited_file.txt";
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);

    // Start building the HTML file
    echo "\n";
    echo "Tab delimited Text to HTML Table\n";
    echo "\n";
    print(tabs_to_table($contents));
    echo "\n";
    echo "\n";
?&gt;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: james</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17817</link>
		<dc:creator>james</dc:creator>
		<pubDate>Sun, 03 Aug 2008 16:07:38 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17817</guid>
		<description>Y.T.  You are correct on both counts.  $inputlist should have read $input.  I think I probably made a snap decision to change the variable name in the function declaration and, for some reason, did not change it in the body of the function.  I am going to go and correct that in the original post.  Thanks for pointing that out.

And yes, I should have also said to invoke the function with

&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;
tabs_to_table($input);
&lt;/pre&gt;

I&#039;ll correct my comment as well.  Thank you very much for the corrections.</description>
		<content:encoded><![CDATA[<p>Y.T.  You are correct on both counts.  $inputlist should have read $input.  I think I probably made a snap decision to change the variable name in the function declaration and, for some reason, did not change it in the body of the function.  I am going to go and correct that in the original post.  Thanks for pointing that out.</p>
<p>And yes, I should have also said to invoke the function with</p>
<pre name="code" class="php">
tabs_to_table($input);
</pre>
<p>I&#8217;ll correct my comment as well.  Thank you very much for the corrections.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Y.T.Lim</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17790</link>
		<dc:creator>Y.T.Lim</dc:creator>
		<pubDate>Sun, 03 Aug 2008 07:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17790</guid>
		<description>Sorry, I&#039;m not familiar with wordpress either :) When I cut-n-paste your original code, quite a few strange characters appeared in the text file. It took me a while to clean them up. Was that a problem of wordpress as well?

I&#039;m curious about this piece of code:

&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;
$input = preg_replace  (’/\t/’  , TAB_REPLACEMENT  , $inputlist);
&lt;/pre&gt;

$inputlist hasn&#039;t been initialized anywhere, how does this work? 

Also, you mentioned using &quot;function tabs_to_table($input);&quot; to invoke the function. Did you really mean &quot;tabs_to_table($input);&quot;?

/Y.T.</description>
		<content:encoded><![CDATA[<p>Sorry, I&#8217;m not familiar with wordpress either <img src='http://james.revillini.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  When I cut-n-paste your original code, quite a few strange characters appeared in the text file. It took me a while to clean them up. Was that a problem of wordpress as well?</p>
<p>I&#8217;m curious about this piece of code:</p>
<pre name="code" class="php">
$input = preg_replace  (’/\t/’  , TAB_REPLACEMENT  , $inputlist);
</pre>
<p>$inputlist hasn&#8217;t been initialized anywhere, how does this work? </p>
<p>Also, you mentioned using &#8220;function tabs_to_table($input);&#8221; to invoke the function. Did you really mean &#8220;tabs_to_table($input);&#8221;?</p>
<p>/Y.T.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: james</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17766</link>
		<dc:creator>james</dc:creator>
		<pubDate>Sun, 03 Aug 2008 00:55:15 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17766</guid>
		<description>Hi, Y.T. Lim.  Sorry if there were faults, but I&#039;m pretty sure what I posted is exactly what I used to do my conversion.  Additionally, I think some of your code got eaten by wordpress, so if you&#039;d like, please post again and wrap your code in [ code]...[ /code] tags (without the spaces) and I think it will come through.  Otherwise, what you posted isn&#039;t going to work for anyone.

Thanks for writing in.  Always nice to have contributions and enhancements!</description>
		<content:encoded><![CDATA[<p>Hi, Y.T. Lim.  Sorry if there were faults, but I&#8217;m pretty sure what I posted is exactly what I used to do my conversion.  Additionally, I think some of your code got eaten by wordpress, so if you&#8217;d like, please post again and wrap your code in [ code]&#8230;[ /code] tags (without the spaces) and I think it will come through.  Otherwise, what you posted isn&#8217;t going to work for anyone.</p>
<p>Thanks for writing in.  Always nice to have contributions and enhancements!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Y.T.Lim</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17744</link>
		<dc:creator>Y.T.Lim</dc:creator>
		<pubDate>Sat, 02 Aug 2008 09:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17744</guid>
		<description>I&#039;m only writing php code occasionally. I tried out this piece of code and it didn&#039;t work. Looks like there are quite a few faults in it. Based on my limited knowledge I managed to get it to work with a few changes:
&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;
&lt;?php

    function tabs_to_table($input) {
       //define replacement constants
       define(&quot;TAB_REPLACEMENT&quot;, &quot;&quot;);
       define(&quot;NEWLINE_REPLACEMENT&quot;, &quot;&quot;);
       define(&quot;TABLE_BEGIN&quot;, &#039;&#039;);
       define(&quot;TABLE_END&quot;, &quot;&quot;);

       //replace all tabs with end-cell, begin-cell
       $input = preg_replace  (&#039;/\t/&#039;  , TAB_REPLACEMENT  , $input);
       //split the list on linebreaks
       $rows = preg_split  (&quot;/\r\n/&quot;  , $input);

       //replace all linebreaks with end-row, begin-row (with or without altRow class)
       $output = &quot;&quot;;
       foreach ($rows as $index =&gt; $row) {
           $output .= $row . sprintf(NEWLINE_REPLACEMENT, ($index%2?&quot;&quot;:&#039; class=&quot;alt&quot;&#039;));
       }

       //build table
       $input = TABLE_BEGIN . $output . TABLE_END;

       return $input;
    }

    // Get Tab delimted text from file
    $filename = &quot;Tab_delimited_file.txt&quot;;
    $handle = fopen($filename, &quot;r&quot;);
    $contents = fread($handle, filesize($filename));
    fclose($handle);

    // Start building the HTML file
    echo &quot;\n&quot;;
    echo &quot;DEK Document Number Register\n&quot;;
    echo &quot;\n&quot;;
    print(tabs_to_table($contents));
    echo &quot;\n&quot;;
    echo &quot;\n&quot;;
?&gt;
&lt;/pre&gt;
It&#039;s not hard to see that the code always adds a blank row at the end.</description>
		<content:encoded><![CDATA[<p>I&#8217;m only writing php code occasionally. I tried out this piece of code and it didn&#8217;t work. Looks like there are quite a few faults in it. Based on my limited knowledge I managed to get it to work with a few changes:</p>
<pre name="code" class="php">
&lt;?php

    function tabs_to_table($input) {
       //define replacement constants
       define("TAB_REPLACEMENT", "");
       define("NEWLINE_REPLACEMENT", "");
       define("TABLE_BEGIN", '');
       define("TABLE_END", "");

       //replace all tabs with end-cell, begin-cell
       $input = preg_replace  ('/\t/'  , TAB_REPLACEMENT  , $input);
       //split the list on linebreaks
       $rows = preg_split  ("/\r\n/"  , $input);

       //replace all linebreaks with end-row, begin-row (with or without altRow class)
       $output = "";
       foreach ($rows as $index =&gt; $row) {
           $output .= $row . sprintf(NEWLINE_REPLACEMENT, ($index%2?"":' class="alt"'));
       }

       //build table
       $input = TABLE_BEGIN . $output . TABLE_END;

       return $input;
    }

    // Get Tab delimted text from file
    $filename = "Tab_delimited_file.txt";
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);

    // Start building the HTML file
    echo "\n";
    echo "DEK Document Number Register\n";
    echo "\n";
    print(tabs_to_table($contents));
    echo "\n";
    echo "\n";
?&gt;
</pre>
<p>It&#8217;s not hard to see that the code always adds a blank row at the end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: james</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-17567</link>
		<dc:creator>james</dc:creator>
		<pubDate>Sun, 27 Jul 2008 18:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-17567</guid>
		<description>Yes, it&#039;s a snippet of php that could be pasted into your php script and then called like this:

&lt;del datetime=&quot;2008-08-04T14:37:15+00:00&quot;&gt;function tabs_to_table($input);&lt;/del&gt;*
&lt;code&gt;tabs_to_table($input);&lt;/code&gt;

Of course, input would have to be read in using php&#039;s fread and such.

* correction suggested by Y.T. Lim - thanks!</description>
		<content:encoded><![CDATA[<p>Yes, it&#8217;s a snippet of php that could be pasted into your php script and then called like this:</p>
<p><del datetime="2008-08-04T14:37:15+00:00">function tabs_to_table($input);</del>*<br />
<code>tabs_to_table($input);</code></p>
<p>Of course, input would have to be read in using php&#8217;s fread and such.</p>
<p>* correction suggested by Y.T. Lim &#8211; thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/comment-page-1/#comment-194</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Wed, 09 Apr 2008 18:46:00 +0000</pubDate>
		<guid isPermaLink="false">http://james.revillini.com/2008/01/30/php-script-convert-excel-or-tab-delimited-file-to-html-table/#comment-194</guid>
		<description>New to php, with some VB and Javascript experience. I&#039;m trying to paste contact info, in an Excel spreadsheet, into my Wordpress blog-static page.

Is the script above a function that I can call? Not for sure how to use it.
Thanks</description>
		<content:encoded><![CDATA[<p>New to php, with some VB and Javascript experience. I&#8217;m trying to paste contact info, in an Excel spreadsheet, into my WordPress blog-static page.</p>
<p>Is the script above a function that I can call? Not for sure how to use it.<br />
Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

