Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Formatting output to txt file' topicStudent Support Forum > General > "Formatting output to txt file"

Next Comment >Help | Reply To Topic
Author Comment/Response
Afshin
05/26/09 2:18pm

I was wondering how can I output pair of numbers generated in a list in Mathematica to a file. Writing it to a file is not a problem but writing these data in a format that i need is my problem.

data = {{1, 1}, {1, 2}, {1, 5}, {1, 6}, {1, 7}, {2, 1}, {2, 4}, {2, 5}, {2,
7}, {2, 8}, {3, 1}, {3, 4}, {3, 5}, {3, 6}, {3, 8}, {4, 2}, {4,
4}, {4, 5}, {4, 6}, {4, 8}, {5, 1}, {5, 3}, {5, 5}, {5, 6}, {5,
8}, {6, 1}, {6, 5}, {6, 6}, {6, 7}, {6, 8}, {7, 1}, {7, 2}, {7,
6}, {7, 7}, {7, 8}, {8, 1}, {8, 2}, {8, 4}, {8, 6}, {8, 8}};

I need to write these in a txt file in this format:

1 1
1 2
1 5
1 6

and so on. Basically firstElement space secondElement and then next pair in the next line. I would appreciate it if you let me know how to write in this specific format to a file. I used OpenWrite and Write functions but can't get the formating right.

I use Write and OutputForm function to get the proper output and have it in a txt file, but the out is not exactly what i expected :( got stuck here.

Any help is greatly appreciated,
Afshin

URL: a.esmaeili@ucalgary.ca,

Subject (listing for 'Formatting output to txt file')
Author Date Posted
Formatting output to txt file Afshin 05/26/09 2:18pm
Re: Formatting output to txt file yehuda ben-s... 05/30/09 07:32am
Re: Re: Formatting output to txt file Afshin 06/03/09 02:26am
Re: Formatting output to txt file Sayantan Das 11/06/10 2:22pm
Next Comment >Help | Reply To Topic