def table_to_file(table, file_out, fmt='', dtype='int16'): """Write data to file, using requested format or infer from file .ext. """ file_fmt, data_fmt = _get_pyo_codes(fmt, dtype, file_out) try: pyo.savefileFromTable(table=table, path=file_out, fileformat=file_fmt, sampletype=data_fmt) except Exception: msg = 'could not save `{0}`; permissions or other issue?' raise IOError(msg.format(file_out))