{"id":5498,"date":"2024-12-31T16:58:07","date_gmt":"2024-12-31T16:58:07","guid":{"rendered":"https:\/\/obsidiansofteducation.com\/?page_id=5498"},"modified":"2024-12-31T16:58:08","modified_gmt":"2024-12-31T16:58:08","slug":"get-or-read-data-from-google-sheet-in-mit-app-inventor","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/get-or-read-data-from-google-sheet-in-mit-app-inventor\/","title":{"rendered":"Get or Read Data from Google Sheet in MIT App Inventor"},"content":{"rendered":"\n<p>Hello friends and welcome to Obsidian Soft,<\/p>\n\n\n\n<p>In today\u2019s MIT App Inventor tutorial, I will teach you a simple and easy way of reading data from a Google sheet and showing it in an MIT App Inventor App.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/25.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new project in App Inventor and name it ReadStudentData.<\/p>\n\n\n\n<p>Make align horizontal center for screen1.<\/p>\n\n\n\n<p>Now, add Listview from the user interface. Make the width 90% and the text color yellow.<\/p>\n\n\n\n<p>Add a Button from the user interface. Rename to loadDataBtn. Make the background color yellow. Font bold, font size 20, shape rounded and text color black.<\/p>\n\n\n\n<p>Add a Web component from connectivity.<\/p>\n\n\n\n<p>Now, either create a Google Sheet if you don\u2019t have one already by clicking on the plus button and writing the data.<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.google.com\/spreadsheets\/u\/0\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.google.com\/spreadsheets\/u\/0<\/a><\/p>\n\n\n\n<p>I am going to use the same sheet that we used in a previous tutorial for sending data to a Google sheet from MIT App Inventor.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Click on the blue share button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/xdxMEuj20vyN7cLR_-JiwI8mUMZFCUQ-EPiQL4D1SSLLXUDYtlBLhvYjMnHmt2DIMMSu9ZAmyPfFQbtk97zXUYArAQQdlyfxK27nrfRaUo4gCygeMxV92a6Vbj27QuBkkN8208yx-3B3bAHNJA9gwjUw535-h334.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>A dialog will open up. Choose \u201cGeneral access\u201d and in the options, choose \u201cAnyone with the link\u201d.&nbsp;<img loading=\"lazy\" decoding=\"async\" height=\"350\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/n0lAPex4nJmnM-tOj5p5wIu5v7jNyzXYz7J2GBBORsZ618IP3SCC-nlQdtZGVVlyGlANmIHMFnnnby2tJH9h3hcDAtI6SlmDWfIhLJEonU7MJBFqTv0izbFNmAEqlVdL9Dp6MYiFfJpidfuY4DjTeuQw560-h350.png\" width=\"560\"><\/p>\n\n\n\n<p>Now, press copy link button and press the done button to close this dialog.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/vLp84ItO3u17-N4hoMFqBGEaYf7Uz9_JbVW00W2xDpffU1se_k-_bii00Wzq8lJt23stZYUeGP9F2vFMgkXZwYkBHfLt1tix2cKYWqV9O9V7XQvPqNLPH9amRsIi7F6gziDvCjBe9Ig17RregZU8usEw503-h314.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Paste the link in some text file. It will look something like this:<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1tLlr0ps7-gxNV1-NCTMS4fYvynvUPu8Cxkz8\/edit?usp=sharing\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.google.com\/spreadsheets\/d\/1tLlr0ps7-gxNV1-NCTMS4fYvynvUPu8Cxkz8\/edit?usp=sharing<\/a><\/p>\n\n\n\n<p>Replace edit?usp=sharing by export?format=csv<\/p>\n\n\n\n<p>Make sure that it is exactly this: export?format=csv<\/p>\n\n\n\n<p>Now copy this entire changed link (don\u2019t use below link and use the one from your own google sheet):<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1tLlr0ps7-gxNV1-NCTMS4fYvynvUPu8Cxkz8\/export?format=csv\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.google.com\/spreadsheets\/d\/1tLlr0ps7-gxNV1-NCTMS4fYvynvUPu8Cxkz8\/export?format=csv<\/a><\/p>\n\n\n\n<p>Go back to your app inventor project and its designer view, and choose web1 component in your project. In its properties, paste the entire link with the updated export part in its Url property.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/Su-ohjpcW47C6SRx7TEnVpzn946NsK7Z-81PWTcXPu8F8geHubOXrktf6T4y85uKD_nR_4KVGOOUS_uimAamTeH9M8_kcCzcdByVWSM1v00MiddzNdIhZsYBT17GVMcc-1rLFQ_dAn3Rh-M9BiBI80w598-h362.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now, go to the blocks section.<\/p>\n\n\n\n<p>Make a global variable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/4BRuakLtU1xkAMwqIzsVTP0HF3Ikc86zt1Iq4JHoPPJhokVBKavbYVLy9KGHBxhMq6dLeEnkbrUwtpwJUJgleibwoxyr_sTE6AP-acoWxRECrN1dyo4iyTGsgeq4S7m3NuNiRYuPGmSJf2YU4DU-S60w640-h45.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Get the button click event for loadDataBtn and call the web component\u2019s Get procedure.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/9GdJLkwqav6vg-AUoSYph9z-6X0UrHjQBrcnwxMZAzUrWJ9jCaBI8V2I0aVoTo8KoUUchRP5uxfVGkWmaoQWYGaVAZHWZP6wEFSMcAjpEmUeJIeIS31X0jAfcCMH2rlral_vywC-aphMmWVGhlyDhJgw518-h160.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now, this procedure Get will trigger the GotText event of Web1 component. So get that event from Web1.<\/p>\n\n\n\n<p>First of all set the sheetData variable to list from csv table block from the lists section: the text coming in from our google sheet is the responseContent.<\/p>\n\n\n\n<p>Remove the first row from this sheetData as it will contain headings: timestamp, name, and age and we don\u2019t want that to show. You don\u2019t need to do this if your sheet doesn\u2019t have column headings.<\/p>\n\n\n\n<p>Next, make a local variable and assign it to an empty list. Now, we will go through our sheetdata which is actually in rows and columns form (table form) using a for loop from control. Each item in this sheetData is actually a row from our actual Google sheet so it has 3 pieces of info: timestamp, name, and age. Hence, it is actually a list too. So, for each item, we are going to get the value inside it for index\/column 2 (name) and index\/column 3 (age) and join them together and add it as an item to our local list: datatobeshown.<\/p>\n\n\n\n<p>Once we are done, we will set our listview elements to our local list.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/y-hl8P3He7gJ5QKp5lqfHDgtyAboxKXhh4LQbLczjJ0zgtyWMUNVmaxCo1wXhPd5KuRSzcSuZs5Il0rb4kIzRqyaumLPFSa-0_uhmFRL4KA6S4FV0-N4RZH6EexAhuevldyVZkjZwqjo8ofj_dmi_dow656-h427.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Think about why I am using a local variable and not a global variable for dataToBeShown list. I would love to hear your answers in the comments.<\/p>\n\n\n\n<p>I hope you liked this tutorial and found this method of reading data from a Google Sheet super easy.<\/p>\n\n\n\n<p>If you like my tutorials, consider supporting me:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/obsidiansoft.gumroad.com\/l\/cxdft\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"372\" height=\"196\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/donate-button-1.png\" alt=\"\" class=\"wp-image-5381\" style=\"width:205px;height:auto\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/donate-button-1.png 372w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2024\/12\/donate-button-1-300x158.png 300w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>You can have a look at the video tutorial here:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<p class=\"responsive-video-wrap clr\"><iframe loading=\"lazy\" title=\"Read Data from Google Sheet in MIT App Inventor (SUPER EASY) | Get Google Sheet Data in App Inventor\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/7Erpfdpkuhg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<\/div><\/figure>\n\n\n\n<p>Please like my videos and share it with your friends and family. Also, subscribe to my channel and press the bell icon so you don\u2019t miss any of the great projects I have planned for you.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.youtube.com\/c\/obsidiansofteducation\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p>Please like my Facebook page and Instagram page for more educational resources and tips.<\/p>\n\n\n\n<p>Facebook:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.facebook.com\/ObsidianSoft\/<\/a><\/p>\n\n\n\n<p>Instagram:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.instagram.com\/obsidiansoftapps\/<\/a><\/p>\n\n\n\n<p>Pinterest:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-pinterest wp-block-embed-pinterest\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oceanwp-oembed-wrap clr\"><iframe loading=\"lazy\" title=\"Obsidian Soft\" src=\"https:\/\/assets.pinterest.com\/ext\/embed.html?grid=obsidiansoft&#038;src=oembed\" height=\"900\" width=\"450\" frameborder=\"0\" scrolling=\"no\" ><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p>For links to free educational apps, have a look at the\u00a0<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/mobile-apps\/\">educational apps page<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends and welcome to Obsidian Soft, In today\u2019s MIT App Inventor tutorial, I will teach you a simple and easy way of reading data from a Google sheet and showing it in an MIT App Inventor App. Create a new project in App Inventor and name it ReadStudentData. Make align horizontal center for screen1. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5498","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/5498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/comments?post=5498"}],"version-history":[{"count":1,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/5498\/revisions"}],"predecessor-version":[{"id":5499,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/5498\/revisions\/5499"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=5498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}