def write(filename, headers, dcols, data, headerlines=[],<EOL>header_char='<STR_LIT:H>', sldir='<STR_LIT:.>', sep='<STR_LIT:U+0020>', trajectory=False,<EOL>download=False):
if sldir.endswith(os.sep):<EOL><INDENT>filename = str(sldir)+str(filename)<EOL><DEDENT>else:<EOL><INDENT>filename = str(sldir)+os.sep+str(filename)<EOL><DEDENT>tmp=[] <EOL>lines=[]<EOL>lengthList=[]<EOL>if os.path.exists(filename):<EOL><INDENT>print('<STR_LIT>'+ filename)<EOL>print('<STR_LIT>')<EOL>s = input('<STR_LIT>')<EOL>if s=='<STR_LIT:Y>' or s=='<STR_LIT:y>' or s=='<STR_LIT>' or s=='<STR_LIT:yes>':<EOL><INDENT>print('<STR_LIT>')<EOL>print('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>print('<STR_LIT>')<EOL>return None<EOL><DEDENT><DEDENT>if len(data)!=len(dcols):<EOL><INDENT>print('<STR_LIT>')<EOL>print('<STR_LIT>')<EOL>return None<EOL><DEDENT>if trajectory:<EOL><INDENT>sep='<STR_LIT:U+0020>'<EOL><DEDENT>for i in range(len(headers)):<EOL><INDENT>if not trajectory:<EOL><INDENT>tmp.append(header_char+'<STR_LIT:U+0020>'+headers[i]+'<STR_LIT:\n>')<EOL><DEDENT>else:<EOL><INDENT>tmp.append(headers[i]+'<STR_LIT:\n>')<EOL><DEDENT><DEDENT>headers=tmp<EOL>tmp='<STR_LIT>'<EOL>for i in range(len(data)): <EOL><INDENT>length=len(dcols[i])<EOL>for j in range(len(data[dcols[i]])): <EOL><INDENT>if len(str(data[dcols[i]][j]))>length: <EOL><INDENT>length=len(str(data[dcols[i]][j]))<EOL><DEDENT><DEDENT>lengthList.append(length)<EOL><DEDENT>print(lengthList)<EOL>tmp='<STR_LIT>'<EOL>tmp1='<STR_LIT>'<EOL>if trajectory:<EOL><INDENT>tmp='<STR_LIT:#>'<EOL><DEDENT>for i in range(len(dcols)):<EOL><INDENT>tmp1=dcols[i]<EOL>if not trajectory:<EOL><INDENT>if len(dcols[i]) < lengthList[i]:<EOL><INDENT>j=lengthList[i]-len(dcols[i])<EOL>for k in range(j):<EOL><INDENT>tmp1+='<STR_LIT:U+0020>'<EOL><DEDENT><DEDENT>tmp+=sep+tmp1<EOL><DEDENT>else:<EOL><INDENT>tmp+='<STR_LIT:U+0020>'+dcols[i]<EOL><DEDENT><DEDENT>tmp+='<STR_LIT:\n>'<EOL>dcols=tmp<EOL>tmp='<STR_LIT>'<EOL>for i in range(len(data[<NUM_LIT:0>])):<EOL><INDENT>for j in range(len(data)):<EOL><INDENT>tmp1=str(data[j][i])<EOL>if len(str(data[j][i])) < lengthList[j]:<EOL><INDENT>l=lengthList[j]-len(str(data[j][i]))<EOL>for k in range(l):<EOL><INDENT>tmp1+='<STR_LIT:U+0020>'<EOL><DEDENT><DEDENT>tmp+=sep+tmp1<EOL><DEDENT>lines.append(tmp+'<STR_LIT:\n>')<EOL>tmp='<STR_LIT>'<EOL><DEDENT>f=open(filename,'<STR_LIT:w>')<EOL>if not trajectory:<EOL><INDENT>for i in range(len(headers)):<EOL><INDENT>f.write(headers[i])<EOL><DEDENT>f.write(dcols)<EOL><DEDENT>else:<EOL><INDENT>f.write(dcols)<EOL>for i in range(len(headerlines)):<EOL><INDENT>f.write('<STR_LIT>'+headerlines[i]+'<STR_LIT:\n>')<EOL><DEDENT>for i in range(len(headers)):<EOL><INDENT>f.write(headers[i])<EOL><DEDENT><DEDENT>for i in range(len(lines)):<EOL><INDENT>f.write(lines[i])<EOL><DEDENT>f.close()<EOL>if download:<EOL><INDENT>from IPython.display import FileLink, FileLinks<EOL>return FileLink(filename)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Method for writeing Ascii files.

Note the attribute name at position i in dcols will be associated
with the column data at index i in data.  Also the number of data
columns(in data) must equal the number of data attributes (in dcols)
Also all the lengths of that columns must all be the same.

Parameters
----------
filename : string
    The file where this data will be written.
Headers : list
    A list of Header strings or if the file being written is of
    type trajectory, this is a List of strings that contain header
    attributes and their associated values which are seperated by
    a '='.
dcols : list
    A list of data attributes.
data : list
    A list of lists (or of numpy arrays).
headerlines : list, optional
    Additional list of strings of header data, only used in
    trajectory data Types. The default is [].
header_char : character, optional
    The character that indicates a header lines. The default is 'H'.
sldir : string, optional
    Where this fill will be written. The default is '.'.
sep : string, optional
    What seperates the data column attributes. The default is '  '.
trajectory : boolean, optional
    Boolean of if we are writeing a trajectory type file. The
    default is False.
download : boolean, optional
    If using iPython notebook, do you want a download link for
    the file you write?
    The default is False.