%% Write Table or Timetable to Parquet File
% Write tabular data into a Parquet file and compare the size of the same tabular data in .csv and .parquet file formats.
% Read the tabular data from the file outages.csv into a table.

T = readtable('outages.csv');

% Write the data to Parquet file format. By default, the parquetwrite function uses the Snappy compression scheme. To specify other compression schemes see 'VariableCompression' name-value pair.

parquetwrite('outagesDefault.parquet',T)

% Get the file sizes and compute the ratio of the size of tabular data in the .csv format to size of the same data in .parquet  format.
% Get size of .csv file.

fcsv = dir(which('outages.csv'));
size_csv = fcsv.bytes

% Get size of .parquet file.

fparquet  = dir('outagesDefault.parquet');
size_parquet = fparquet.bytes

% Compute the ratio.

sizeRatio = ( size_parquet/size_csv )*100 ;
disp(['Size Ratio = ', num2str(sizeRatio) '% of original size'])

% Copyright 2018 The MathWorks, Inc.