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.
> 

Diana, files are, by default, placed in Directory[].  To export to a two 
column text file, create a n x 2 table first.

In[1]:= lst = {4, 5, 10, 11, 3, 79};

In[3]:= Export["file.txt", Partition[lst, 2], "Table"];

In[4]:= Directory[]

Out[4]= "D:\\Documents"

Note that Parition will drop nonpairs, in this case.  See documentation 
for Partition for more complex cases.

Igor C. Antonio
Wolfram Research, Inc.

--
To email me personally, remove the dash.


  • Prev by Date: Strange timing of many assignments
  • Next by Date: Re: Trying to export two column table to text file
  • Previous by thread: Trying to export two column table to text file
  • Next by thread: Re: Trying to export two column table to text file