MATLABからAW​Sにテキストファイル​を送信したい

22 views (last 30 days)
ryota arai
ryota arai on 23 Jul 2020
Commented: Kojiro Saito on 5 Aug 2020
MATLABからAWSのAmazonS3にテキストファイルを送信したいと考えています.
AWSでアクセスキー,アクセスシークレットキーを発行し,MATLABのコードに入力し,
上記のサイトをもとに通信しようと考えたのですが,うまくいきません.
そもそもこのサイトが通信するために必要なページなのかも分からなくなってきました.
もし,通信した経験がある方やノウハウをご存じの方がいらっしゃったら教えていただきたいです.
よろしくお願いいたします.
  2 Comments
Kojiro Saito
Kojiro Saito on 27 Jul 2020
S3からのデータ読み書きを行うには、上記のドキュメントでの設定が必要になります。
MATLABでどのようなコマンドを実行してどのようなエラーが出ているか、S3に関する部分だけでも抜粋してお教えいただくことはできますでしょうか?
ryota arai
ryota arai on 27 Jul 2020
コードは以下です.
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
filename = 'C:\Users\wellness_root\Downloads\test1.txt';
setenv('AWS_ACCESS_KEY_ID', '-----------------');
setenv('AWS_SECRET_ACCESS_KEY', '------------------------------');
% ds = tabularTextDatastore('s3://wellness1resized/test.txt');
ds = tabularTextDatastore('s3://buckets/wellness1resized/test1/','TreatAsMissing', 'NA', 'SelectedVariableNames', {'ArrDelay'});
tt = ds;
tt = sortrows(rmmissing(tt));
write('s3://wellness1resized/test3/',tt);
% ↑データを書き込むフォルダの指定(空または存在しないフォルダーでなければならない)
% データを読み戻すには、関数 datastore を使用
ds = datastore('s3://wellness1resized/test3');
% ↑AWSに書き込み先とファイル名の指定
tt = tall(ds);
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
S3にフォルダの作成は出来ているのですが,S3にテキストファイルを送ることが出来ません.
他に調べても全く実現出来そうなヒントなどが見つかりません.よろしくお願いいたします.

Sign in to comment.

Accepted Answer

Kojiro Saito
Kojiro Saito on 30 Jul 2020
関数writeはtall配列を書き込む関数で、datastoreを直接書き込むことができません。
tt = ds;
のところを
tt = tall(ds);
にすればS3にファイルが書き込まれると思います。
  4 Comments
ryota arai
ryota arai on 4 Aug 2020
S3に書き込めました!ありがとうございます!!
Kojiro Saito
Kojiro Saito on 5 Aug 2020
良かったです。もしよろしければ回答の採用をしていただけると幸いです。

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 入門 in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!