Message Boards Message Boards

0
|
4185 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Data exportation to file .txt with the function Write.

Posted 9 years ago

Hi I am quite new to Mathematica and I am having problems with this code. The length of the numbers I need to print (eleven-digits) does not allow the disposition i want in the file.txt, i.e. i need a 12-colum distribution and this exportation wraps my file as you can see in my OUTPUT.

my code

  xfile = OpenWrite["C:\\Users\\xyz\\Desktop\\file.txt", FormatType -> StandardForm];
    For[i = 0, i < 11, i++,
     For[j = 0, j < 11, j++, Write[xfile, 11111111111, " ", 11111111111, " ", 11111111111, " ", 
        11111111111, " ", 11111111111, " ", 11111111111, " ", 11111111111,
         " ", 11111111111, " ", 11111111111, " ", 11111111111, " ",  
        11111111111, " ", 11111111111]
      ]]
    Close[xfile]

part of the file.txt

11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

  11111111111 11111111111 11111111111 11111111111 11111111111 11111111111
11111111111 11111111111 11111111111 11111111111 11111111111 11111111111 

Does someone knows what I need to modify to reach the configuration I want? Thank you.

POSTED BY: dapi dapi
Posted 9 years ago

Is this what you are trying to do?

xfile = OpenWrite["C:\\Users\\xyz\\Desktop\\file.txt", FormatType -> StandardForm];
    For[i = 0, i < 11, i++, 
 For[j = 0, j < 11, j++, 
  WriteString[xfile, 
   StringJoin@Map[ToString, #] &@{11111111111, " ", 11111111111, " ", 
     11111111111, " ", 11111111111, " ", 11111111111, " ", 
     11111111111, " ", 11111111111, " ", 11111111111, " ", 
     11111111111, " ", 11111111111, " ", 11111111111, " ", 
     11111111111, "\n"}]]] 
Close[xfile]
POSTED BY: Juan Miranda
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract