Message Boards Message Boards

GROUPS:

Data exportation to file .txt with the function Write.

Posted 8 years ago
3828 Views
|
1 Reply
|
0 Total Likes
|

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