1 / 23

Web Component: Accessing the Web and CSV 靜宜大學資管系 楊子青

Web Component: Accessing the Web and CSV 靜宜大學資管系 楊子青. 1. CSV. Ccomma-Separated Values 格式 ( 逗點分隔值 ) 一種文字檔格式,可用來在應用程式之間交換試算表的資料。 檔案中的每一行都代表試算表中的一列 試算表中的每一個儲存格通常以逗點區隔。不過也可使用其他字元來區隔欄位,例如,跳格字元。. 建立 CSV 實例. 開啟記事本,輸入一列資料,每個欄位以逗點隔開,存檔 ( 例如 test1.csv) 存檔前,存檔類型,請先選擇:所有檔案. 將 CSV 上傳至網頁空間.

vlad
Télécharger la présentation

Web Component: Accessing the Web and CSV 靜宜大學資管系 楊子青

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Component: Accessing the Web and CSV靜宜大學資管系 楊子青

  2. 1. CSV • Ccomma-Separated Values格式(逗點分隔值) • 一種文字檔格式,可用來在應用程式之間交換試算表的資料。 • 檔案中的每一行都代表試算表中的一列 • 試算表中的每一個儲存格通常以逗點區隔。不過也可使用其他字元來區隔欄位,例如,跳格字元。

  3. 建立CSV實例 • 開啟記事本,輸入一列資料,每個欄位以逗點隔開,存檔 (例如test1.csv) • 存檔前,存檔類型,請先選擇:所有檔案

  4. 將CSV上傳至網頁空間 • 例如上傳至kitty.cs.pu.edu.tw • 下載,並Double click開啟看看: http://www.cs.pu.edu.tw/~tcyang/test1.csv

  5. 2. 讀取CSV內容之程式設計 • 使用者介面設計

  6. 程式碼

  7. 執行結果

  8. (1) 若讀不到檔案

  9. 判斷是否成功讀取CSV檔之程式碼

  10. (2) 讀取CSV多筆資料→OK

  11. (3) 輸入中文則發生亂碼

  12. 解決方法:存檔時,編碼請選UTF-8

  13. (4) 讀取CSV個別值,至二維陣列

  14. (4) 讀取CSV個別值,至二維陣列

  15. 從二維陣列,讀取第2筆記錄

  16. 從二維陣列,讀取第1筆第4欄

  17. 從二維陣列,讀取每筆第4欄

  18. 3. 實例應用:Yahoo股市即時股價 • http://tw.stock.yahoo.com/ • 輸入股票代號,例如2330台積電

  19. 股票代號查詢

  20. Yahoo股市提供的查詢網址 • http://www.gummy-stuff.org/Yahoo-data.htm

  21. 輸入網址,Yahoo自動產生對應CSV • http://finance.yahoo.com/d/quotes.csv?f=ghl1&s=2330.tw • f後的參數 • g當日最低點, h當日最高點, l1 (前一碼是L小寫)成交價 • s後的參數: 2330股市代號, .tw台灣股市

  22. 練習:撰寫程式,即時查詢股價

  23. 參考程式碼及執行實例

More Related