{"id":90,"date":"2016-02-13T17:24:32","date_gmt":"2016-02-13T17:24:32","guid":{"rendered":"http:\/\/intelligentonlinetools.com\/blog\/?p=90"},"modified":"2016-03-11T02:26:12","modified_gmt":"2016-03-11T02:26:12","slug":"how-to-write-to-a-google-spreadsheet-with-a-perl-script","status":"publish","type":"post","link":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/","title":{"rendered":"How to Write to a Google Spreadsheet with a Perl Script"},"content":{"rendered":"<p>Google Docs is one of many cloud computing document-sharing services and provides an alternative to MS Office applications such as MS Excel. This post will show how to write data to Google Docs Spreadsheet and read data back from the same spreadsheet using perl programming language.<\/p>\n<p>Google Sheets is an online spreadsheet application that lets you create and format spreadsheets and simultaneously work with other people. Here are the links for more information:<br \/>\n <a href=\"https:\/\/support.google.com\/drive\/answer\/140784?ref_topic=20322&#038;rd=1\" target=\"_blank\">Overview of Google Sheets<\/a><br \/>\n <a href=\"https:\/\/support.google.com\/drive\/answer\/141195?hl=en&#038;ref_topic=20329\" target=\"_blank\">Create and save a spreadsheet<\/a> <\/p>\n<p>First you need to create spreadsheet where the script will put some data. You need Google account for this. To create a new spreadsheet, go to your <a href=\"https:\/\/drive.google.com\/\" target=\"_blank\">Google Drive<\/a> , click the red &#8216;Create&#8217; button, and select &#8216;Spreadsheet&#8217; from the drop-down menu. As soon as you name the spreadsheet or start typing, Google Sheets will automatically save your work every few seconds.<\/p>\n<p>At the top of the spreadsheet, you&#8217;ll see text that indicates when your spreadsheet was last saved. Now when you have spreadsheet you can call it in perl script by its name and write data to it. Perl module Net::Google::Spreadsheets provides all needed functions to do this. Below is the basic script that is opening spreadsheet, iterate through several rows and columns, multiply row index by column index and put it to the cell. Then it iterates again and read the values and print them to screen. Obviously you need to put real account information, spreadsheet and sheet names into this script to run it. <\/p>\n<p>use Net::Google::Spreadsheets;<br \/>\n my $service = Net::Google::Spreadsheets->new( username => &#8216;xxxxxxx&#8217;, password => &#8216;xxxxxxx&#8217; );<br \/>\n my @spreadsheets = $service->spreadsheets();<br \/>\n my $spreadsheet = $service->spreadsheet( { title => &#8216;spreadsheet_name&#8217; } );<br \/>\n my $worksheet1 = $spreadsheet->worksheet( { title => &#8216;Sheet1&#8217; } ); <\/p>\n<p># get a cell<br \/>\nmy $cell = $worksheet1->cell({col => 1, row => 5});<br \/>\n# update input value of a cell<br \/>\n$cell->input_value(&#8216;new value&#8217;);<br \/>\n# print the value of cell<br \/>\nmy $cell = $worksheet1->cell({col => 1, row => 5});<br \/>\nprint &#8220;\\n&#8221;;<br \/>\nprint $cell->input_value;<br \/>\nprint &#8220;\\n&#8221;;<br \/>\nfor($i=1; $i<4; $i++) \n { for($j=1; $j<4; $j++) \n   { $cell = $worksheet1->cell({col => $i, row => $j});              $cell->input_value($i*$j);<br \/>\n} }<br \/>\nfor($i=1; $i<4; $i++)\n { for($j=1; $j<4; $j++)\n     { $cell = $worksheet1->cell({col => $i, row => $j});<br \/>\n       print $cell->input_value;<br \/>\n       print &#8221; &#8220;;<br \/>\n}<br \/>\nprint &#8220;\\n&#8221;; } <\/p>\n<p>To test that it really put values to spreadsheet you can access your spreadsheet at any time by opening your spreadsheet at <a href=\"http:\/\/drive.google.com\" target=\"_blank\">Google Drive<\/a> after you run perl script. So now we can create different programs that export or import data to spreadsheet. <\/p>\n<p><strong>References:<\/strong><\/p>\n<p> <a href=\"http:\/\/upandrunning.bplans.com\/2013\/05\/08\/4-free-alternatives-to-microsoft-excel\/\" target=\"_blank\">4 Free Alternatives To Microsoft Excel by Richard Wilson on May 8, 2013<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Docs is one of many cloud computing document-sharing services and provides an alternative to MS Office applications such as MS Excel. This post will show how to write data to Google Docs Spreadsheet and read data back from the same spreadsheet using perl programming language. Google Sheets is an online spreadsheet application that lets &#8230; <a title=\"How to Write to a Google Spreadsheet with a Perl Script\" class=\"read-more\" href=\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[7],"tags":[],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Write to a Google Spreadsheet with a Perl Script - Machine Learning Applications<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Write to a Google Spreadsheet with a Perl Script - Machine Learning Applications\" \/>\n<meta property=\"og:description\" content=\"Google Docs is one of many cloud computing document-sharing services and provides an alternative to MS Office applications such as MS Excel. This post will show how to write data to Google Docs Spreadsheet and read data back from the same spreadsheet using perl programming language. Google Sheets is an online spreadsheet application that lets ... Read more\" \/>\n<meta property=\"og:url\" content=\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Machine Learning Applications\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-13T17:24:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-11T02:26:12+00:00\" \/>\n<meta name=\"author\" content=\"owygs156\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"owygs156\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/\",\"url\":\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/\",\"name\":\"How to Write to a Google Spreadsheet with a Perl Script - Machine Learning Applications\",\"isPartOf\":{\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#website\"},\"datePublished\":\"2016-02-13T17:24:32+00:00\",\"dateModified\":\"2016-03-11T02:26:12+00:00\",\"author\":{\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478\"},\"breadcrumb\":{\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/intelligentonlinetools.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Write to a Google Spreadsheet with a Perl Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#website\",\"url\":\"http:\/\/intelligentonlinetools.com\/blog\/\",\"name\":\"Machine Learning Applications\",\"description\":\"Artificial intelligence, data mining and machine learning for building web based tools and services.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/intelligentonlinetools.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478\",\"name\":\"owygs156\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g\",\"caption\":\"owygs156\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Write to a Google Spreadsheet with a Perl Script - Machine Learning Applications","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/","og_locale":"en_US","og_type":"article","og_title":"How to Write to a Google Spreadsheet with a Perl Script - Machine Learning Applications","og_description":"Google Docs is one of many cloud computing document-sharing services and provides an alternative to MS Office applications such as MS Excel. This post will show how to write data to Google Docs Spreadsheet and read data back from the same spreadsheet using perl programming language. Google Sheets is an online spreadsheet application that lets ... Read more","og_url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/","og_site_name":"Machine Learning Applications","article_published_time":"2016-02-13T17:24:32+00:00","article_modified_time":"2016-03-11T02:26:12+00:00","author":"owygs156","twitter_card":"summary_large_image","twitter_misc":{"Written by":"owygs156","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/","url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/","name":"How to Write to a Google Spreadsheet with a Perl Script - Machine Learning Applications","isPartOf":{"@id":"http:\/\/intelligentonlinetools.com\/blog\/#website"},"datePublished":"2016-02-13T17:24:32+00:00","dateModified":"2016-03-11T02:26:12+00:00","author":{"@id":"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478"},"breadcrumb":{"@id":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/how-to-write-to-a-google-spreadsheet-with-a-perl-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/intelligentonlinetools.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Write to a Google Spreadsheet with a Perl Script"}]},{"@type":"WebSite","@id":"http:\/\/intelligentonlinetools.com\/blog\/#website","url":"http:\/\/intelligentonlinetools.com\/blog\/","name":"Machine Learning Applications","description":"Artificial intelligence, data mining and machine learning for building web based tools and services.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/intelligentonlinetools.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478","name":"owygs156","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g","caption":"owygs156"}}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7h1IJ-1s","jetpack-related-posts":[{"id":76,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/downloading-stock-market-data-to-a-google-spreadsheet-with-a-perl-script\/","url_meta":{"origin":90,"position":0},"title":"Downloading Stock Market Data to a Google Spreadsheet with a Perl Script","date":"February 13, 2016","format":false,"excerpt":"In this post will be shown how to download stock market with perl script into Google spreadsheet. Once the data is loaded in Google spreadsheet you can do trend or forecasting analysis and build charts using Google Docs functionality. Perl script helps to automate downloading process, to replace manual downloading\u2026","rel":"","context":"In &quot;Stock data analysis&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/13\/adding-stock-market-data-to-a-google-spreadsheet-with-a-perl-script\/","url_meta":{"origin":90,"position":1},"title":"Adding Stock Market Data to a Google Spreadsheet with a Perl Script","date":"February 13, 2016","format":false,"excerpt":"In the previous post it was shown how to download stock data data prices into Google spreadsheet using perl script. This post will extend this script by considering situation when we just want to add the latest data to the existing spreadsheet with the data downloaded previously. For example first\u2026","rel":"","context":"In &quot;Stock data analysis&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":123,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/20\/calculating-indicators-for-stock-data-forecasting\/","url_meta":{"origin":90,"position":2},"title":"Calculating Indicators for Stock Data Forecasting","date":"February 20, 2016","format":false,"excerpt":"In the previous posts was shown how to download stock data into Google spreadsheet using perl script. Here we will look how to add other data indicators based on downloaded stock data prices and volume. The use for stock data prediction of such indicators based on stock data that is\u2026","rel":"","context":"In &quot;Stock data analysis&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":125,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/02\/20\/calculating-indicators-for-stock-data-forecasting-2\/","url_meta":{"origin":90,"position":3},"title":"Calculating Indicators for Stock Data Forecasting","date":"February 20, 2016","format":false,"excerpt":"In the previous posts was shown how to download stock data into Google spreadsheet using perl script. Here we will look how to add other data indicators based on downloaded stock data prices and volume. The use for stock data prediction of such indicators based on stock data that is\u2026","rel":"","context":"In &quot;Stock data analysis&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/01\/30\/making-tree-map-chart\/","url_meta":{"origin":90,"position":4},"title":"Making Tree Map Chart","date":"January 30, 2016","format":false,"excerpt":"In information visualization and computing, treemapping is a method for displaying hierarchical data by using nested rectangles.[1] Below will be discussed some ways how to create tree map chart. 1. Google Code You can create tree map with Google chart tools. The example can be found on Google Code.[2] You\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1070,"url":"http:\/\/intelligentonlinetools.com\/blog\/2017\/03\/12\/how-to-write-to-a-google-sheet-with-a-python-script\/","url_meta":{"origin":90,"position":5},"title":"How to Write to a Google Sheet with a Python Script","date":"March 12, 2017","format":false,"excerpt":"My post How to Write to a Google Spreadsheet with a Perl Script that was published some time ago is still getting a lot of visitors. This is not surprising as cloud computing is a fast-growing business. Below is the chart of number of searches for phrase \"Google Sheet\" from\u2026","rel":"","context":"In &quot;Python Scripts&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/03\/Google-sheet-accessed-through-web-300x179.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/90"}],"collection":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":2,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":93,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions\/93"}],"wp:attachment":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}