List print out
- To: mathgroup at yoda.ncsa.uiuc.edu
- Subject: List print out
- From: billl at helmholtz.sdsc.edu
- Date: Sat, 10 Aug 91 14:41:52 -0700
Is there a sensible way to print out a list into a file so that it appears as columns and rows (spaces and newlines) instead of as a list with curly brackets. I'm currently using : printout[file_,ls_] := Block[{out = OpenWrite[file], lim1 = Length[ls],lim2 = Length[ls[[1]]]}, For[x=1,x<=lim1,x++, For[y=1,y<lim2,y++,WriteString[out,ls[[x]][[y]]," "]]; WriteString[out,ls[[x]][[y]],"\n"]]; Close[out]] which is not very elegant nor very fast for large lists. I've tried fancier things like: printout[file_,ls_] := Block[{out = OpenWrite[file]}, WriteString[out,ToString[TableForm[ls,TableSpacing->{0,1}]]]; WriteString[out,"\n"]; Close[out]] but this puts multiple spaces between numbers so that the columns line up. There must be an easy way to do this. What is it? ________________________________________________________________ Bill Lytton billl at helmholtz.sdsc.edu Salk Institute tel 619 453 4100 x124 10010 N. Torrey Pines Rd. fax 619 587 0417 La Jolla, CA 92037 ________________________________________________________________