%% Write Spreadsheet File to Cloud Storage
% Create a tall table referencing the tsunamis.xlsx data file, which contains time-stamped data about the location, magnitude, and cause of tsunamis.

ds = spreadsheetDatastore('tsunamis.xlsx');
T = tall(ds)

%
% Combine the Year, Month, Day, Hour, Minute, and Second variables into a single datetime variable, and then remove those variables from the table. Remove any rows that contain missing data.

T.DateTime = datetime(T.Year, T.Month, T.Day, T.Hour, T.Minute, T.Second);
T(:,3:8) = [];
TT = rmmissing(T)

%
% Write the table as a spreadsheet file to a remote location in Amazon S3® storage. To read or write data to Amazon S3 you must set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables using the credentials for your account. For more information, see Work with Remote Data.
% setenv('AWS_ACCESS_KEY_ID', 'YOUR_AWS_ACCESS_KEY_ID');
% setenv('AWS_SECRET_ACCESS_KEY', 'YOUR_AWS_SECRET_ACCESS_KEY');
%
% location = 's3://bucketname/preprocessedData/';
% write(location, TT, 'FileType', 'spreadsheet')
% To read the data back, use datastore to point to the remote location where the data now resides.
% ds = datastore(location);
% tt = tall(ds);
%
%
% Copyright 2019 The MathWorks, Inc.