
從 Dropbox 讀取 CSV 檔案至 App Inventor
今天要來教如何從 Dropbox,讀取我們上傳的 CSV 檔案,並將資料顯示在 App Inventor。
那麼首先,我們先來準備一個 CSV 檔案,可以自己用 Excel 製作一個,但是用 Excel 做好的 CSV 檔,還要再用記事本開啟後,將檔案以 UTF-8 的編碼方式,重新另存新檔,這樣給 App Inventor 讀取才不會顯示亂碼。
為求方便,我直接從政府資料開放平台,下載一個檔案來做示範。
1. 直接點選下方連結,進入政府資料開放平台。
高雄市電影院現況 | 政府資料開放平臺 (data.gov.tw)
進入後下載 CSV 檔案

2. 瀏覽器搜尋 Dropbox,進入官網後,登入自己的帳號。
登入後按上傳鈕,把剛剛下載的 CSV 檔案,上傳到 Dropbox。


接著要來共享檔案
滑鼠移到 CSV 檔案,在 movie.csv 檔案的右邊,可以看到共享按鈕。

共享鈕點下去後,再點設定。

然後點建立連結

好了之後就跳出去,再複製連結到記事本。

接著要來改一下網址
把連結網址前面的 www,改成 dl。

Google Drive 也有這種功能,但要改的網址太長了!很難記,相比之下 Dropbox 就方便許多。
接著要來製作 App
3. 開啟 App Inventor 並新增一個專案「readCSV」
需要元件如下:

切換到程式設計並增加下圖的方塊

網址輸入自己的,設定網址後就執行 Get 請求。
然後要用取得文字的方塊,對資料做進一步的處理。
實際執行 App
以下是執行結果:

此次教學就到這邊,如有問題歡迎下方留言。
如果覺得文章內容還不錯的話,麻煩請幫我點個讚!感謝
可以多點幾次喔~~
第一次點讚需使用 Google 或 Facebook 帳號註冊

一個評論
JamesBang
!