<?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: Manish Manghwani</title>
    <description>The latest articles on DEV Community by Manish Manghwani (@manishmanghwani).</description>
    <link>https://dev.to/manishmanghwani</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%2F104493%2Fe8a51fad-0da8-4fea-b7b2-ccdbe0160288.png</url>
      <title>DEV Community: Manish Manghwani</title>
      <link>https://dev.to/manishmanghwani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manishmanghwani"/>
    <language>en</language>
    <item>
      <title>Google Spreadsheet Acolyte</title>
      <dc:creator>Manish Manghwani</dc:creator>
      <pubDate>Fri, 07 Aug 2020 20:34:34 +0000</pubDate>
      <link>https://dev.to/manishmanghwani/google-spreadsheet-acolyte-2aab</link>
      <guid>https://dev.to/manishmanghwani/google-spreadsheet-acolyte-2aab</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Repetition is the first step to become monotonous &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Philosophy behind making the package
&lt;/h2&gt;

&lt;p&gt;We usually tend to do things that are repetitive in nature and waste two most crucial entities : &lt;strong&gt;&lt;em&gt;time and energy&lt;/em&gt;&lt;/strong&gt;. Both are &lt;strong&gt;inversely proportional&lt;/strong&gt; to each other and yet we require both to survive. Former one &lt;strong&gt;&lt;em&gt;validates our presence&lt;/em&gt;&lt;/strong&gt; and latter one is &lt;strong&gt;&lt;em&gt;vital for presence&lt;/em&gt;&lt;/strong&gt;. coming back from philosophy and jumping straight to terminal&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Google Spreadsheet acolyte is a laravel package to dump records from spreadsheet into database table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usefulness
&lt;/h2&gt;

&lt;p&gt;It removes dependency from CSV or any other dumping extension. It eradicates the need of intervention with database. You just need to have one active database connection defined within your .env file and table must exist within that database, that's the bare minimum it requires as of now. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;You can install the package via composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require manish-manghwani/google-spreadsheet-acolyte
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Meanwhile you can fulfil other dependencies as follow&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;You must have one google account. &lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Login to your developer console via that google account using the link &lt;a href="https://console.developers.google.com"&gt;https://console.developers.google.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Create new project&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Enable Google Sheets Api&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create Service Accounts&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 6
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Download Credentials.json&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 7
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create one spreasheet from same google account and share it with the service account id that you created just now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After Completing above steps, use the credentials.json file and move it into root directory. (Since they are crucial credentials, you may wish to add it's name in .gitignore file too)&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Install the package via composer using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require manish-manghwani/google-spreadsheet-acolyte
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Get the Google Spreadsheet Url. It may look similiar to this &lt;a href="https://docs.google.com/spreadsheets/d/1auqTdpciifOA6PH5JbSoRFegdgdr48icvgwqsfWqrqI/edit#gid=0"&gt;https://docs.google.com/spreadsheets/d/1auqTdpciifOA6PH5JbSoRFegdgdr48icvgwqsfWqrqI/edit#gid=0&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should have name of the credential file that was downloaded from service account (for eg: credentials.json)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should have table name in which data will be inserted (for eg: dummy)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With above things in place you can run below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan import:sheet --file-url=https://docs.google.com/spreadsheets/d/1auqTdpciifOA6PH5JbSoxRFegdgdr48icvgwqsfWqrqI/edit#gid=0 --table-name=dummy --credentials-file-name=credentials
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  NOTE:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If sheet is not shared with service account email id, it will fail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;First row of spreadsheet must be exactly same as of columns present in table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spreadsheet name should not be changed it must be Sheet1&lt;br&gt;
Data to be inserted must be present in Sheet1&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>sql</category>
      <category>laravel</category>
      <category>spreadsheet</category>
    </item>
  </channel>
</rss>
