<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: How do you create text files from a spreadsheet?</title>
	<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet/</link>
	<description>Comments on Ask MetaFilter post How do you create text files from a spreadsheet?</description>
	<pubDate>Wed, 02 May 2007 23:02:55 -0800</pubDate>
	<lastBuildDate>Wed, 02 May 2007 23:02:55 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: How do you create text files from a spreadsheet?</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet</link>	
		<description>How do you create text files from a spreadsheet? &lt;br /&gt;&lt;br /&gt; I export a query from my  Access database to an excel spreadsheet. I would like to take 3 fields and create a text file from them. I would like the name of the file to contain 2 of those fields and inside the file to contain another field. How would I go about doing that? So I would like this 400 record query to become 400 txt files.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2007:site.61854</guid>
		<pubDate>Wed, 02 May 2007 22:55:00 -0800</pubDate>
		<dc:creator>bigmusic</dc:creator>
		
			<category>excel</category>
		
			<category>access</category>
		
	</item> <item>
		<title>By: bigmusic</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet#931031</link>	
		<description>Office XP(2002) if that&apos;s important.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.61854-931031</guid>
		<pubDate>Wed, 02 May 2007 23:02:55 -0800</pubDate>
		<dc:creator>bigmusic</dc:creator>
	</item><item>
		<title>By: zixyer</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet#931040</link>	
		<description>I don&apos;t think there&apos;s a way to do this without writing some sort of script or macro.&lt;br&gt;
&lt;br&gt;
You can save it to a .csv file and do some shell-script trickery to generate the text files. I wouldn&apos;t recommend this approach since Windows gives you such a crippled shell, but for what it&apos;s worth, the command would be something like this:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;for /f &quot;skip=1 tokens=1,2,3 delims=,&quot; %i in (file.csv) do @echo %k &amp;gt; %i%j.txt&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Go to Start/Programs/Accessories/Command Prompt and type &lt;code&gt;for /?&lt;/code&gt; for more information on the for command.&lt;br&gt;
&lt;br&gt;
It would also be easy to do with a macro.&lt;br&gt;
&lt;code&gt;&lt;br&gt;
Sub GenerateTextFiles()&lt;br&gt;
  For Each Row In Selection.Rows&lt;br&gt;
    With Row.Cells&lt;br&gt;
      Open .Item(1) &amp;amp; .Item(2) &amp;amp; &quot;.txt&quot; For Output As #1&lt;br&gt;
      Print #1, .Item(3).Text&lt;br&gt;
      Close #1&lt;br&gt;
    End With&lt;br&gt;
  Next Row&lt;br&gt;
End Sub&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Let me know if you have any questions.  I haven&apos;t tested either of these solutions very much, hopefully someone will be able to point out if I&apos;ve made a mistake.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.61854-931040</guid>
		<pubDate>Wed, 02 May 2007 23:25:05 -0800</pubDate>
		<dc:creator>zixyer</dc:creator>
	</item><item>
		<title>By: special-k</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet#931041</link>	
		<description>You would need to need some sort of programming language to acheive this (e.g. PHP). You could also do this easily in something like R.&lt;br&gt;
&lt;br&gt;
Save the excel file as a comma seperated file (.csv)&lt;br&gt;
Read that in a script&lt;br&gt;
Go through each row and save column 3 into Column1_Column_2.txt&lt;br&gt;
rinse, repeat (via  a loop).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.61854-931041</guid>
		<pubDate>Wed, 02 May 2007 23:26:54 -0800</pubDate>
		<dc:creator>special-k</dc:creator>
	</item><item>
		<title>By: zixyer</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet#931047</link>	
		<description>Keep in mind that if you go the .csv route you&apos;ll need to handle some special cases if any of your cells contain commas or quotes.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.61854-931047</guid>
		<pubDate>Wed, 02 May 2007 23:47:38 -0800</pubDate>
		<dc:creator>zixyer</dc:creator>
	</item><item>
		<title>By: bigmusic</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet#931080</link>	
		<description>I went with the for method. Thanks zixyer!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.61854-931080</guid>
		<pubDate>Thu, 03 May 2007 03:12:26 -0800</pubDate>
		<dc:creator>bigmusic</dc:creator>
	</item><item>
		<title>By: flabdablet</title>
		<link>http://ask.metafilter.com/61854/How-do-you-create-text-files-from-a-spreadsheet#931093</link>	
		<description>The for method, as given, is going to put extra spaces before and after the text it writes to the file.  You could fix that by replacing the &quot;echo&quot; part of it with&lt;br&gt;
&lt;code&gt;&lt;br&gt;
@echo.%k&amp;gt;%i%j.txt&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Also note that you can save this for command in a .bat or .cmd file, leave it in the same folder with your .csv file, and double-click it to generate the .txt files.  If you do this, you&apos;ll have to change every occurrence of % in the command to %% in the batch file.&lt;br&gt;
&lt;br&gt;
It&apos;s almost certainly going to end up misbehaving in data-dependent ways, though.  If this were my problem, I&apos;d be writing on-click handlers for a button in an Access form that just spits out the .txt files directly.  The code would mostly be similar to what zixyer suggested for the macro option.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.61854-931093</guid>
		<pubDate>Thu, 03 May 2007 04:41:55 -0800</pubDate>
		<dc:creator>flabdablet</dc:creator>
	</item>
	</channel>
</rss>
