Re: Re: Re: Help needed with new Export (v. 6)

*To*: mathgroup at smc.vnet.net*Subject*: [mg84291] Re: [mg84267] Re: [mg84255] Re: Help needed with new Export (v. 6)*From*: Murray Eisenberg <murray at math.umass.edu>*Date*: Mon, 17 Dec 2007 19:20:09 -0500 (EST)*Organization*: Mathematics & Statistics, Univ. of Mass./Amherst*References*: <fhh7uo$92p$1@smc.vnet.net> <200712161036.FAA23863@smc.vnet.net> <200712170646.BAA03045@smc.vnet.net>*Reply-to*: murray at math.umass.edu

Although this works if the original data is a table, it will not if the data is an unnested list, for in that case the items are still written with one per line, i.e., each item is treated as a separate record. For example: x = Table[RandomReal[], {5}]; Export["numbers.txt", x, "Table", "FieldSeparators" -> " "] Import["numbers.txt"] 0.1693010791540126 0.7625360043925844 0.8417661120259938 0.5710465219735799 0.544981416130305 (You can see the one-number-per-line in the written file, too.) The fix in this case is: Export["numbers.txt",Partition[x,Length[x]],"Table", "FieldSeparators"->" "] Carl Woll wrote: > C.O. wrote: > >> ...Is there now a way to use "Export" to >> write a list of numbers to a file which has, say, spaces as delimeters >> rather than tabs (as in TSV) or commas (as in CSV)? I was able to do >> it easily in version 5, without doing any string manipulation.... >> >> > Perhaps you can use: > > Export[file, data, "Table", "FieldSeparators" -> " "] > > Carl Woll > Wolfram Research > >> >> On Nov 15, 3:44 am, Curtis Osterhoudt <c... at lanl.gov> wrote: >> >>> In v. 5, I used a Mathematica function to import .fig files, do some >>> manipulation to them, and then export the files again. The only way I could >>> find to retain the proper formatting of the .fig files was to use the >>> ConversionOptions option in Export; the relevant part of the code is >>> something like: >>> >>> Export[ newFileName, myNewExpression, "CSV", >>> ConversionOptions->{"FieldSeparator" -> " "}] >>> >>> where "CSV" was used because it somehow keptXFighappy with the results, and >>> the commas are replaced with spaces. "Table" does not work as an export >>> format, asXFigneeds single spaces between most of the exported values. >>> >>> It seems that the new version of Mathematica does not like >>> ConversionOptions, as the Help entry says "As of Version 6.0, >>> ConversionOptions is superseded by capabilities in Import and Export." >>> However, I can't figure out what new capabilities might replace my old >>> behavior. Is there a quick way to fix my old function, or am I going to have >>> to go through the stream operation tango? -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305

**References**:**Re: Help needed with new Export (v. 6)***From:*"C.O." <costerhoudt@gmail.com>

**Re: Re: Help needed with new Export (v. 6)***From:*Carl Woll <carlw@wolfram.com>