3
$\begingroup$

Is there a rule that tells Mathematica to set a semicolon at the end of each line (except of the last one)?

My MWE is:

Export["..\\Thesis\\Hamiltonian_stark.dat",Table[j + 10 i, {i, 0, 9}, {j, 0, 9}]]

But I want something like

Export["..\\Thesis\\Hamiltonian_stark.dat",Table[j + 10 i, {i, 0, 9}, {j, 0, 9}],{EndOfLine->';/n'}]
$\endgroup$

1 Answer 1

10
$\begingroup$

How about:

Export["t.txt", Table[j + 10 i, {i, 0, 9}, {j, 0, 9}], 
 "List", 
 "LineSeparators" -> ";\n"]
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
{10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
{20, 21, 22, 23, 24, 25, 26, 27, 28, 29};
{30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
{40, 41, 42, 43, 44, 45, 46, 47, 48, 49};
{50, 51, 52, 53, 54, 55, 56, 57, 58, 59};
{60, 61, 62, 63, 64, 65, 66, 67, 68, 69};
{70, 71, 72, 73, 74, 75, 76, 77, 78, 79};
{80, 81, 82, 83, 84, 85, 86, 87, 88, 89};
{90, 91, 92, 93, 94, 95, 96, 97, 98, 99}

If you should happen to want a different format, try this:

Export["t.txt", Table[j + 10 i, {i, 0, 9}, {j, 0, 9}], "Table", 
 "LineSeparators" -> ";\n"]
 0  1   2   3   4   5   6   7   8   9;
10  11  12  13  14  15  16  17  18  19;
20  21  22  23  24  25  26  27  28  29;
30  31  32  33  34  35  36  37  38  39;
40  41  42  43  44  45  46  47  48  49;
50  51  52  53  54  55  56  57  58  59;
60  61  62  63  64  65  66  67  68  69;
70  71  72  73  74  75  76  77  78  79;
80  81  82  83  84  85  86  87  88  89;
90  91  92  93  94  95  96  97  98  99
$\endgroup$
2
  • $\begingroup$ But to use the data, I want to omit the brackets. $\endgroup$
    – strpeter
    Commented Jun 26, 2013 at 16:20
  • $\begingroup$ @strpeter you should have said ...:) $\endgroup$
    – cormullion
    Commented Jun 26, 2013 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.