updated script to insert to FT or dump to CSV based on 'dump_to_csv' flag