<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: oschertar</title>
    <description>The latest articles on DEV Community by oschertar (@oschertar).</description>
    <link>https://dev.to/oschertar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F922423%2Ff6ee951a-4af1-47d4-9199-c0a3d5717ade.jpeg</url>
      <title>DEV Community: oschertar</title>
      <link>https://dev.to/oschertar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oschertar"/>
    <language>en</language>
    <item>
      <title>How to export your data from Google Sheets to JSON</title>
      <dc:creator>oschertar</dc:creator>
      <pubDate>Fri, 09 Sep 2022 12:40:55 +0000</pubDate>
      <link>https://dev.to/oschertar/how-to-export-your-data-from-google-sheets-to-json-3ih8</link>
      <guid>https://dev.to/oschertar/how-to-export-your-data-from-google-sheets-to-json-3ih8</guid>
      <description>&lt;p&gt;Many times I have the need to use the data I've been working with in Google Sheets in other tool. For example, last week a non technical colleague sent me a data collection in tabular format inside a Google Sheet. Part of my job is automating the integration of this data with other tools. I didn't want to copy and paste everything, so I wondered if there was a way to export this data easily. JSON is the de-facto standard for data interexchange on the Internet and a format almost of the tools I work with are able to understand. I decided then to solve the problem once and for all. Do you want to know how? Keep reading.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1
&lt;/h3&gt;

&lt;p&gt;For the solution we are going to implement to work correctly, we will need to freeze the first row or header from our data. So, select the top row and then click on &lt;em&gt;View &amp;gt; Freeze &amp;gt; 1 Row&lt;/em&gt;. If you don't do that, &lt;strong&gt;the script will throw an error&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdkt64giz9wy2y31d605.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdkt64giz9wy2y31d605.png" alt="Freezing top row" width="787" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2
&lt;/h3&gt;

&lt;p&gt;In this case, we are going to use the Apps Script tool that Google Sheet has integrated in its interface. This allows us to include Javascript code to add new functionalities to our spreadsheet.&lt;/p&gt;

&lt;p&gt;Access into this tool doing click in &lt;em&gt;Extensions &amp;gt; Apps Script&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg61gak5kxn7uznldox1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg61gak5kxn7uznldox1u.png" alt="How to access Apps Script" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3
&lt;/h3&gt;

&lt;p&gt;In the opened window, paste the following script found in this &lt;a href="https://gist.githubusercontent.com/pamelafox/1878143/raw/6c23f71231ce1fa09be2d515f317ffe70e4b19aa/exportjson.js" rel="noopener noreferrer"&gt;Gist&lt;/a&gt;* and change the title to "Export JSON".&lt;/p&gt;

&lt;p&gt;Then, save this script by clicking &lt;em&gt;Save&lt;/em&gt; and run the code with the corresponding button. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5hljk5l85heh4wrfghk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5hljk5l85heh4wrfghk.png" alt="Save and execute the script" width="800" height="653"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Google may require additional permissions in order to do this correctly so accept them.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojgiikp4blj510lfq8dp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojgiikp4blj510lfq8dp.png" alt="Accept permissions" width="593" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4
&lt;/h3&gt;

&lt;p&gt;Go back to the Google Sheets tab and refresh, and &lt;em&gt;voilà&lt;/em&gt;, a new option will appear in the spreadsheet to export your data to JSON format. Congrats!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1w4l2w4lspdbbzzdy6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1w4l2w4lspdbbzzdy6q.png" alt="New option" width="800" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you click this new option you got this 💪&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xb4rwgs8pttjy52e2gb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xb4rwgs8pttjy52e2gb.png" alt="Export JSON" width="757" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to improve
&lt;/h2&gt;

&lt;p&gt;Some of the next steps would be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Try to adapt this process to an addon rather than a script.&lt;/li&gt;
&lt;li&gt;Investigate whether this process could be adapted to all spreadsheets. Currently, if we want to export data to JSON, we have to repeat all these steps, over and over again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thanks to Google's Apps Script tool, we can add new options and functionalities to our spreadsheet. In this case, we have managed to automate the process of exporting data to JSON format, as I said before, a de-facto standard for data interexchange on the Internet.&lt;/p&gt;

&lt;p&gt;In cases with a lot of data, this new option is very helpful, because we don’t have to pass the data manually to other tools doing copy and paste.&lt;/p&gt;

&lt;p&gt;*Thanks to &lt;a href="https://github.com/pamelafox" rel="noopener noreferrer"&gt;Pamela Fox&lt;/a&gt; for share the script&lt;/p&gt;

</description>
      <category>json</category>
      <category>javascript</category>
      <category>googlesheets</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
