#!/usr/bin/env python3

import sys
import argparse
from hestia_earth.utils.table import format_for_upload


parser = argparse.ArgumentParser(description='Format data for upload.')
parser.add_argument('--input-file', type=str, required=True,
                    help='The path of the CSV or JSON file.')
parser.add_argument('--output-file', type=str,
                    help='The path of where to store the pivoted CSV. Adds "-formatted" suffix by default to input.')
args = parser.parse_args()


def main():
    src = args.input_file
    dest = args.output_file or src.split('.')[0] + '-formatted.csv'
    pd = format_for_upload(src)
    pd.to_csv(dest, index=None)


if __name__ == '__main__':
    sys.exit(main())
