Re: 2D array to tab delimited file
- To: mathgroup at smc.vnet.net
- Subject: [mg25329] Re: [mg24695] 2D array to tab delimited file
- From: Claudius Schnörr <schnoerr at mailzone.com>
- Date: Sat, 23 Sep 2000 03:35:52 -0400 (EDT)
- References: <200008040519.BAA05094@smc.vnet.net> <8q78a6$t7l@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello Leon, perhaps this helps a little. It's just a cut from some Source I have written some years ago: ma = {{1, 3.23435E5, 2}, {4, 5, 6}} file = OpenWrite["test.dat"]; WriteString[file, ToString[TableForm[ma, TableSpacing -> {0, 20}]]] Close[file]; The 20 in TableSpacing means that each column has at least 20 characters in width. The spaces between could then be replaced with tabs by a macro in the emacs-editor or some shell-script. Claudius Christopher Lee French wrote: > > Leon, > > Array[Plus, {10, 10}] > // ToString > // StringReplace[#, {", " -> "\t", "}, " -> "\n", "{" -> "", "}" -> ""}] & > // WriteString[OpenWrite["filename.tab"], #] &; > > Streams[] > // Drop[#, 2] & > // Close /@ # &; > > ReadList["filename.tab", Word, RecordLists -> True, WordSeparators -> {"\t"}] > // ToExpression > // MatrixForm > > allot can be done with direct string manipulation > > CLFrench > > L Lobo wrote: > > > I am creating a large 2D array and need to save it to file (tab delimited) > > which is then read by LabVIEW. I have tried using Export but the spaces > > created between columns varies. I have looked up old postings on this > > newsgroup but the solutions I've seen seem to be a bit longwinded. I have > > version 4. Any ideas? > > > > -- > > Leon Lobo > > Optical Engineering Group > > Department of Mechanical Engineering > > Loughborough > > Leics. > > LE11 3TU -- ---------------------------------------------------------------- Dr.-Ing. Claudius Schn"orr Tel: ++49-(0)211-5591570 Sigmaringenstr. 2 40547 D"usseldorf / Germany e-mail: schnoerr at mailzone.com ----------------------------------------------------------------