キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.

Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.

言語を選択 翻訳バーを非表示
最初に公開されたスレッドを表示

JSLでループを書くのを手伝ってください

shasheminassab
Level IV

URLから入手できるデータをダウンロードする必要があります。

 

http://www.arpalazio.net/main/aria/sci/basedati/chimici/BDchimici/RM/MedieGiornaliere/RM_PM2.5_ 2019年_gg.txt

 

異なる年のデータをダウンロードするには、に示すように、URLの年を変更する必要があります。 1990年から2021年までのJSLでループを作成し、データをテーブルに入れたいと思います。 私はJSLを初めて使用するので、そのための助けをいただければ幸いです。

 

 

この投稿のオリジナルは 、English (US) で書かれており、ユーザビリティ向上のため自動翻訳機能を使用して表示しています。コメントを投稿すると、オリジナルの言語(English (US))やご指定の言語 でも表示されます。

1 件の受理された解決策

受理された解決策
jthi
Super User

Re:JSLでループを書くのを手伝ってください

これには、ループ(forループ)、URLを作成する方法(eval insert)、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を処理する非常に簡単な方法です(少し怠惰です)。

6件の返信6
jthi
Super User

Re:JSLでループを書くのを手伝ってください

これには、ループ(forループ)、URLを作成する方法(eval insert)、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を処理する非常に簡単な方法です(少し怠惰です)。

この投稿のオリジナルは 、English (US) で書かれており、ユーザビリティ向上のため自動翻訳機能を使用して表示しています。コメントを投稿すると、オリジナルの言語(English (US))やご指定の言語 でも表示されます。

shasheminassab
Level IV

Re:JSLでループを書くのを手伝ってください

どうもありがとう@jthi 。これは非常に役立ちます。

フォローアップの質問があり、それを手伝ってくれないかと思っていました。 ほぼ同じ方法でデータをダウンロードする必要がある別のデータベースがあります(つまり、URLの年の値を変更します)。 URLは次のとおりです。

 

https://www.arb.ca.gov/aqmis2/pickdl_hrly.php?param=OZONE&units=007&year=2021&county_name=--COUNTY--&basin=SC-South+Coast&latitude=--PART+OF+STATE--&report= PICKDATA&order = bathin%2Ccounty_name%2Cs.name&submit = Retrieve + Data&ptype = aqd&std15 =&o3switch = new&hours = all&statistic =&qselect = Screened&start_mon = 1&start_day = 1&mon = 12&day = 31&submit = All + Sites&rows = 29

 

唯一の違いは、このURLからデータを取得するには、そのページの[データを取得]ボタンをクリックする必要があることです。 JSLを介してこれを行う方法はありますか?

この投稿のオリジナルは 、English (US) で書かれており、ユーザビリティ向上のため自動翻訳機能を使用して表示しています。コメントを投稿すると、オリジナルの言語(English (US))やご指定の言語 でも表示されます。

jthi
Super User

Re:JSLでループを書くのを手伝ってください

私の知る限り、JMPを使用してWebサイトの要素をクリックすることはできませんが、HTTPリクエストを使用してデータを取得できる可能性があります。 このためには、リクエストがどのように行われるかを理解する必要があります(ブラウザの開発者ツールがこれに役立ちます)。

この投稿のオリジナルは 、English (US) で書かれており、ユーザビリティ向上のため自動翻訳機能を使用して表示しています。コメントを投稿すると、オリジナルの言語(English (US))やご指定の言語 でも表示されます。

shasheminassab
Level IV

Re: Help with writing a loop in JSL

I see! good to know, thanks a lot.

 

Sina

Craige_Hales
Super User

Re: Help with writing a loop in JSL

Yes, the developer tools make this easier than learning HTML Forms.

 

Using web browser developer tools to examine the link that was used to download a fileUsing web browser developer tools to examine the link that was used to download a file

The link has parameters, which you can modify with JSL before opening it with open(). FF shown above, chrome is similar, but arranged differently.

Your original link requested 12 months of data. The site did not want to send that much, I stopped at 31jan instead of 31dec.

Craige
shasheminassab
Level IV

Re: Help with writing a loop in JSL

@Craige_Hales This is immensely helpful and saves me a lot of time. Thanks a lot!!!

おすすめの記事

No recommendations found