<?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>google sheets Archives &#8212; Stampede: the strategic design &amp; technology company</title>
	<atom:link href="https://stampede-design.com/blog/tag/google-sheets/feed/" rel="self" type="application/rss+xml" />
	<link>https://stampede-design.com/blog/tag/google-sheets/</link>
	<description>We are creating better worlds though thoughtful design and technology. Connect with us!</description>
	<lastBuildDate>Tue, 07 Apr 2026 09:03:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.6</generator>

<image>
	<url>https://stampede-design.com/wp-content/uploads/2024/02/cropped-Stampede-Favicon-old-32x32.png</url>
	<title>google sheets Archives &#8212; Stampede: the strategic design &amp; technology company</title>
	<link>https://stampede-design.com/blog/tag/google-sheets/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Generating TaffyDB Data File from Google Sheets</title>
		<link>https://stampede-design.com/blog/generating-taffydb-data-file-from-google-sheets/</link>
					<comments>https://stampede-design.com/blog/generating-taffydb-data-file-from-google-sheets/#comments</comments>
		
		<dc:creator><![CDATA[Shaiful Borhan]]></dc:creator>
		<pubDate>Wed, 30 Apr 2014 17:20:20 +0000</pubDate>
				<category><![CDATA[Field Notes]]></category>
		<category><![CDATA[data tools]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[google sheets]]></category>
		<category><![CDATA[taffydb]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">https://stampede-design.com/blog/?p=5127</guid>

					<description><![CDATA[<p>Shaiful shares some cool coding tricks using Google App Scripts for converting tabular data from Google Sheets to the format understood by a Javascript database called TaffyDB.</p>
<p>The post <a href="https://stampede-design.com/blog/generating-taffydb-data-file-from-google-sheets/">Generating TaffyDB Data File from Google Sheets</a> appeared first on <a href="https://stampede-design.com">Stampede: the strategic design &amp; technology company</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="lead"><em>A little introduction</em>; in one of our most recent Shopify customization projects involving a store selling Subaru vehicle parts, the client wanted to have a cascading dropdown list to filter the products displayed to the user based on the vehicle selected.</p>
<div class="full"><img fetchpriority="high" decoding="async" width="306" height="337" src="https://stampede-design.com/wp-content/uploads/2014/05/Screenshot_on_5.2.2014_at_4.22.10_PM.png" alt="Cascading dropdown list" class="size-full wp-image-5132" srcset="https://stampede-design.com/wp-content/uploads/2014/05/Screenshot_on_5.2.2014_at_4.22.10_PM.png 306w, https://stampede-design.com/wp-content/uploads/2014/05/Screenshot_on_5.2.2014_at_4.22.10_PM-272x300.png 272w" sizes="(max-width: 306px) 100vw, 306px" /><p class="capt_block">The requirement: Cascading dropdown list</p></div>
<p>This being on Shopify, the only way to code this custom feature is by getting creative with Javascript. It was then when I discovered about <a href="http://www.taffydb.com" target="_blank">TaffyDB</a> as the medium to store the 100+ odd rows of vehicle data. I played around with some hard-coded sample data using TaffyDB (and jQuery) and managed to get the cascading dropdown to work properly in Shopify. <em>Perhaps the steps can be outlined in another blog post.</em></p>
<p>Now we move on to the main gist of this post. The client had the vehicle data populated nicely in Google Sheets. My next big task was to reformat these data to a TaffyDB-compatible data file. Below is a snapshot of the Google Sheet and the corresponding TaffyDB data, which is essentially a JS array of objects. The cool part is to automate this conversion process.</p>
<div class="full"><a href="https://stampede-design.com/wp-content/uploads/2014/05/Screenshot_on_5.2.2014_at_4.13.06_PM.png" class="thickbox"><img decoding="async" src="https://stampede-design.com/wp-content/uploads/2014/05/Screenshot_on_5.2.2014_at_4.13.06_PM-500x142.png" alt="Sample data in Google Sheet." class="size-blog_post_full wp-image-5151" /></a><p class="capt_block">Sample data in Google Sheet (click to enlarge)</p></div>
<pre class="brush: jscript; title: ; notranslate">
var car = TAFFY(&#x5B;
{year:&quot;2002&quot;, make:&quot;Subaru&quot;, model:&quot;WRX&quot;, trim:&quot;Sedan&quot;, bolt:&quot;5x100&quot;, e_family:&quot;EJ&quot;, e_code:&quot;EJ20&quot;}, 
{year:&quot;2002&quot;, make:&quot;Subaru&quot;, model:&quot;WRX&quot;, trim:&quot;Wagon&quot;, bolt:&quot;5x100&quot;, e_family:&quot;EJ&quot;, e_code:&quot;EJ20&quot;}, 
{year:&quot;2003&quot;, make:&quot;Subaru&quot;, model:&quot;WRX&quot;, trim:&quot;Sedan&quot;, bolt:&quot;5x100&quot;, e_family:&quot;EJ&quot;, e_code:&quot;EJ20&quot;}, 
{year:&quot;2003&quot;, make:&quot;Subaru&quot;, model:&quot;WRX&quot;, trim:&quot;Wagon&quot;, bolt:&quot;5x100&quot;, e_family:&quot;EJ&quot;, e_code:&quot;EJ20&quot;}
]);
</pre>
<p>Enter <a href="https://developers.google.com/apps-script/quickstart/macros" target="_blank">Google Apps Script</a>. This tool is a godsend because it allows you to use Javascript to programmatically manipulate data in your spreadsheet. To access Google Apps Script in Google Sheets, go to <i>Tools -&gt; Script Editor</i>.</p>
<p>After going through a few tutorials, I managed to come out with a fairly decent code for performing this conversion process.</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 * Retrieves all the rows in the active spreadsheet that contain data and generate a TaffyDB data array from it
 */
function readRows() {
  var sheet = SpreadsheetApp.openById('SPREADSHEET_ID_HERE').getActiveSheet();   // The value of key= variable in the URL
  
  // This represents ALL the data
  var range = sheet.getRange(5, 1, 1000, 20);   // Starts reading from row #5 column #1 (cell A5). Read as far as 1000 rows and 20 columns (for future data entries).
  var values = range.getValues();
  var output = '';
  var index = &#x5B;];
  var row_array = &#x5B;];
  var row = &quot;&quot;;
  
  // The main loop that goes through each cell within the selected range. i is row, j is column
  for (var i in values) {
    var cell_array = &#x5B;];
    for (var j in values&#x5B;i]) {
      if(i == 0) {   // i == 0 is row #5, this is the column variable name
        if (values&#x5B;i]&#x5B;j]) {
          index.push(values&#x5B;i]&#x5B;j]);
        }        
      } else {   // car data starts at row #7 onwards
        if (values&#x5B;i]&#x5B;j]) {
          cell_array.push(index&#x5B;j] + ':&quot;' + values&#x5B;i]&#x5B;j] + '&quot;');   // compose the car data cell by cell for the current row
        }
      }
      
    }
    
    if(i &gt; 0) {
     if(cell_array.length &gt; 0) {
        row = cell_array.join(', ');   // join the individual cells car data for the current row with commas to form a complete row data
        row_array.push(row);
      }
    }
    
  }
  
  output = row_array.join('}, n{');   // join the individual rows with curly braces and commas to form a complete database

  output = 'var car = TAFFY(&#x5B;{' + output + '}]);';   // finalizing the TaffyDB format
  
  Logger.log(output);
  //return output;
};
</pre>
<p>To test this code out, simply enter your spreadsheet ID in line 5 and change the range number accordingly in line 8. The <em>Logger.log</em> command in line 44 is used for testing the output in the script editor console. In the production version, I have a few more extra codes to add a dropdown menu in the Google Sheets UI that users can click to download the updated TaffyDB JS data file and then simply drop it into Shopify.</p>
<p>The post <a href="https://stampede-design.com/blog/generating-taffydb-data-file-from-google-sheets/">Generating TaffyDB Data File from Google Sheets</a> appeared first on <a href="https://stampede-design.com">Stampede: the strategic design &amp; technology company</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stampede-design.com/blog/generating-taffydb-data-file-from-google-sheets/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
