def write(self, magicc_input, filepath):
self._filepath = filepath<EOL>self.minput = deepcopy(magicc_input)<EOL>self.data_block = self._get_data_block()<EOL>output = StringIO()<EOL>output = self._write_header(output)<EOL>output = self._write_namelist(output)<EOL>output = self._write_datablock(output)<EOL>with open(<EOL>filepath, "<STR_LIT:w>", encoding="<STR_LIT:utf-8>", newline=self._newline_char<EOL>) as output_file:<EOL><INDENT>output.seek(<NUM_LIT:0>)<EOL>copyfileobj(output, output_file)<EOL><DEDENT>
Write a MAGICC input file from df and metadata

Parameters
----------
magicc_input : :obj:`pymagicc.io.MAGICCData`
    MAGICCData object which holds the data to write

filepath : str
    Filepath of the file to write to.