MathGroup Archive 2007

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

Search the Archive

Re: Trying to export two column table to text file

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 *)
(* Checking where is the base user directory so we are sure that you 
have read/write access on it *)
(* 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:

5.2 for Microsoft Windows (June 20, 2005)

C:\Documents and Settings\Jean-Marc

C:\Documents and Settings\Jean-Marc\sequence.txt

C:\Documents and Settings\Jean-Marc\sequence.txt


  • Prev by Date: Re: is there a better way to iterate this?
  • Next by Date: Re: Trouble with a system of equations
  • Previous by thread: Re: Trying to export two column table to text file
  • Next by thread: Re: Trying to export two column table to text file