MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: export some data to a specified file?


At 09:04 PM 3/1/2003, liwen liwen wrote:

>Hi;
>
>I want to export some data to a specified file, for instance,
>Spring.txt, I use 'FileName ' as the local file name.
>     But the function I develop only export the data to a file named
>'FileName'but not Spring.txt.
>     How can I achieve this?
>
>       Thanks.
>     Liwen
>
>
>ExportDatas[FileName_,DataToBeExport_]:=Module[{},
>       (DataToBeExport>>FileName);];
>
>In[13]:=
>DataToBeExport={{0,0},{5,4}};
>ExportDatas[Spring.txt,DataToBeExport]

The >> is parsed in a special way. To allow people to use it without 
quoting the filename, the filename isn't evaluated but turned directly into 
a string. To avoid that behavior, you can use the FullForm of the same command.

ExportDatas[FileName_,DataToBeExport_] :=
Put[DataToBeExport, FileName]

DataToBeExport={{0,0},{5,4}};
ExportDatas["Spring.txt",DataToBeExport]

Or you could just use Export

Export["Spring.txt", DataToBeExport, "Expression"]

-Dale



  • Prev by Date: Re: debug compiled function
  • Next by Date: Re: Is Sort stable?
  • Previous by thread: export some data to a specified file?
  • Next by thread: Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc