MB-7102: Export to csv file if specified

By default, csv output to stdout. But if .csv file is specified,
it is desirable to export to specified file.
Uppper level directories will be created if nonexist

Change-Id: Ie7159d93908a642a578ac71c5dffd158b31ebb15