def _write_int(fname, data, append=True):
<EOL>data_ex = pexdoc.exh.addex(ValueError, "<STR_LIT>")<EOL>fos_ex = pexdoc.exh.addex(<EOL>OSError, "<STR_LIT>"<EOL>)<EOL>data_ex((len(data) == <NUM_LIT:0>) or ((len(data) == <NUM_LIT:1>) and (len(data[<NUM_LIT:0>]) == <NUM_LIT:0>)))<EOL>try:<EOL><INDENT>pmisc.make_dir(fname)<EOL>mode = "<STR_LIT:w>" if append is False else "<STR_LIT:a>"<EOL>if sys.hexversion < <NUM_LIT>:  <EOL><INDENT>with open(fname, mode) as file_handle:<EOL><INDENT>csv.writer(file_handle, delimiter="<STR_LIT:U+002C>").writerows(data)<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>with open(fname, mode, newline="<STR_LIT>") as file_handle:<EOL><INDENT>csv.writer(file_handle, delimiter="<STR_LIT:U+002C>").writerows(data)<EOL><DEDENT><DEDENT><DEDENT>except (IOError, OSError) as eobj:<EOL><INDENT>fos_ex(True, _MF("<STR_LIT>", fname, "<STR_LIT>", eobj.strerror))<EOL><DEDENT>
Write data to CSV file with validation.