Message Boards Message Boards

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

[?] Output a Table as a Column?

Posted 6 years ago

Hallo! I have a problem.

The code

Clear@"Global`*"     (*Speicher löschen*)

test1[k_] = k;
test2[n_] = n;
text = "abc";

myrow[y_] = y;
mycolumn[x_] = x; 
mycell[k_, n_] := 
 ToString@myrow[n] <> " " <> ToString@mycolumn[k] <> " " <> 
  ToString@test1[k] <> " " <> ToString@test2[n] <> " " <> 
  ToString@text 

list2 = Table[mycell[k, n], {k, 1, 2}, {n, 1, 3}]
Export["Test.txt", list2, "Table"]  

gives me a txt-file with

1 1 1 1 abc 2 1 1 2 abc 3 1 1 3 abc
1 2 2 1 abc 2 2 2 2 abc 3 2 2 3 abc

How can I export a textfile which contains the same stuff rowwise? That means:

1 1 1 1 abc
2 1 1 2 abc
3 1 1 3 abc
1 2 2 1 abc
2 2 2 2 abc
3 2 2 3 abc

Do you have any idea? Thanks a lot!

POSTED BY: cis cis

You can use Flatten:

Export["Test.txt", list2 // Flatten, "Table"]
POSTED BY: Gianluca Gorni
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