Re: Printing Lists to file without {}
- To: mathgroup at smc.vnet.net
- Subject: [mg66083] Re: Printing Lists to file without {}
- From: albert <awnl at arcor.de>
- Date: Sat, 29 Apr 2006 03:40:15 -0400 (EDT)
- References: <e2srqd$3o2$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, just generate the string you want to see in the file in mathematica and write that string, something like: In[1]:= lst = {1,2,3,4,5} Out[1]= {1, 2, 3, 4, 5} In[2]:= line = StringJoin[StringTake[StringJoin[ ({ToString[#1], ","} & ) /@ lst], {1, -2}], "\n"] Out[2]= 1,2,3,4.,0.00005 In[3]:= WriteString["file.csv",line] It should be fairly easy to adopt this to your needs with the use of the String*-functions and probably something like NumberForm for finetuning the formatting of the numbers. Just look that stuff up in the help browser... If speed matters, this is probably not optimal. For one it might be more efficient to collect some lines and write them with one call to WriteString. Using regular expressions to convert a whole bunch of lines to what you want them to look like could also be more efficient than complicated combinations of StringJoin/StringTake and the like, but that I don't know. hth, albert