我需要通過 url 下載可用的數據:
http://www.arpalazio.net/main/aria/sci/basedati/chimici/BDchimici/RM/MedieGiornaliere/RM_PM2.5_ 2019年_gg.txt
下載不同年份的數據,需要修改url中的年份,如圖紅色的. 我想在 JSL 中編寫一個循環,該循環運行從 1990 年到 2021 年,並將數據放入表中。 我是 JSL 的新手,因此非常感謝這方面的任何幫助。
為此,您需要做幾件事:循環(for 循環)、構建 url 的方法(eval 插入)、從 url 加載數據的方法(使用正確的參數打開)以及組合數據的方法(連接)。
Names Default To Here(1);
//We can use Eval Insert to replace ^temp_year^ in the string
dl_url = "http://www.arpalazio.net/main/aria/sci/basedati/chimici/BDchimici/RM/MedieGiornaliere/RM_PM2.5_^temp_year^_gg.txt";
dt = New Table(); //table to collect results
//for-loop
For(i = 1990, i <= 2021, i++,
temp_year= Char(i);
year_url = Eval Insert(dl_url);
//downloaded first one file by hand -> opened in JMP to get Open with correct parameters and replaced file path with URL
Try(
dt_temp = Open(
year_url,
Import Settings(
End Of Line(CRLF, CR, LF),
End Of Field(Spaces, Space, CSV(0)),
Strip Quotes(1),
Use Apostrophe as Quotation Mark(0),
Use Regional Settings(0),
Scan Whole File(1),
Treat empty columns as numeric(0),
CompressNumericColumns(0),
CompressCharacterColumns(0),
CompressAllowListCheck(0),
Labels(1),
Column Names Start(1),
Data Starts(2),
Lines To Read("All"),
Year Rule("20xx")
)
);
dt << Concatenate(dt_temp, Append to first table(1));
Close(dt_temp, no save);
,
Show(exception_msg)
);
);
Concatenate 應該能夠通過創建缺失值來處理缺失的列,而 Try 是處理不存在的 URL 的相當簡單的方法(有點懶)。
據我所知,您無法使用 JMP 單擊網站中的元素,但您可以使用 HTTP 請求來獲取數據。 為此,您必須弄清楚請求是如何完成的(瀏覽器的開發人員工具可能對此有所幫助)。