Re: Trying to export two column table to text file
- To: mathgroup at smc.vnet.net
- Subject: [mg77870] Re: Trying to export two column table to text file
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Mon, 18 Jun 2007 07:10:11 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f532jq$38q$1@smc.vnet.net>
Diana wrote:
> All,
>
> I am trying to convert a list of numbers, such as:
>
> {4, 5, 10, 11, 3, 79, ...}
>
> to a two column text file such as:
>
> 1 4
> 2 5
> 3 10
> 4 11
> 5 3
> 6 79 ...
>
> Let me use the following example. Assume that I have defined an
> "r[n_]" function of arbitrary integers.
>
> tt = Flatten[Prepend[Table[Numerator[r[n]], {n, 4, 100}], {1, 1, 5}]]
>
> tttable = Table[{j, tt[[j]]}, {j, 1, Length[tt]}]
>
> Export["sequence.txt", tttable]
>
> I get an output line of "sequence.txt", but then can not find the
> file.
>
> I am using Windows Vista, and believe I am searching the whole
> computer.
>
> Diana M.
----- copy and paste in a Mathematica notebook the code below -----
(* Just to be sure what Mathematica version is used *)
$Version
(* Checking where is the base user directory so we are sure that you
have read/write access on it *)
$HomeDirectory
(* Now we create an absolute pathname for the file sequence.txt to
ensure that it will be created at the desired location *)
file = ToFileName[$HomeDirectory, "sequence.txt"]
(* Now we export the data to the specified location -- note that the
file will be created even if tttable is not defined: in this case the
contents of sequence.txt is just the string tttable *)
Export[file, tttable]
(* If the export command has succeeded the full pathname is returned --
otherwise an error message is displayed. Now with Windows Eplorer go to
the above location: you must find the file sequence.txt there. If the
file is not there, I have no idea what is going on on your system -- I
have tested all the command I have suggested to you since my first reply
and they have always been working as expected -- but this is not a
Mathematica issue. Check with the IT department. *)
----- end of the code to be copied -----
Evaluating the above code, you should get similar outputs:
Out[2]=
5.2 for Microsoft Windows (June 20, 2005)
Out[4]=
C:\Documents and Settings\Jean-Marc
Out[6]=
C:\Documents and Settings\Jean-Marc\sequence.txt
Out[8]=
C:\Documents and Settings\Jean-Marc\sequence.txt
Regards,
Jean-Marc