Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13141 > unrolled thread

Re: Export with append??

Started byAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
First post2013-01-15 04:28 +0000
Last post2013-01-15 04:28 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Export with append?? Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2013-01-15 04:28 +0000

#13141 — Re: Export with append??

FromAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
Date2013-01-15 04:28 +0000
SubjectRe: Export with append??
Message-ID<kd2lt9$coc$1@smc.vnet.net>
Hello,

With a command like

Export["myfile.dat", results, "List" ]

is there a way to append the results to an existing myfile.dat, rather
than creating or overwriting an existing file?

thanks for your help,

Maarten


Hi, Maarten,
A simple workaround is to import your file, append a new file to it and then - to export the combined list. Assume that your mathematica notebook entitled "trialImportExport.nb"  is situated in the same folder as the already existing list entitled "myfile.dat".
To be precise I generated the file myfile.dat with the list:
{25, 36, 49}
in it. Assume further that I want to append the list
{a,b,c}
to it. Then the code

lst1=Import[NotebookDirectory[]<>"myfile.dat"]//Flatten;
lst2={a,b,c};
lst3=Append[lst1,lst2]//Flatten;
Export[NotebookDirectory[]<>"myfileNew.dat",lst3]

Does the job. The output cell below:
D:\Documents and Settings\ABo\My Documents\Works\Mathematica_works\Examples\TrialFiles\myfileNew.dat

shows that the file has been successfully exported.
I intentionally gave the resulting file a new name, "myfileNew.dat", to check the result, but the old name can also be given to it.

Have fun, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu<mailto:alexei.boulbitch@iee.lu>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web