0

I want to Export a list of lists in Table format with \t or blank as delimiter. Unfortunatelly Mathematica 4.0 does not have the FieldSeparator option aviable.

Is there still a way to program this without the FieldSeparator command?

Example:

    list=Table[Random[Real,90],{2}]&/@Range[6];

I have searched this site and adapted an answer to a similar question:

    Export["list.txt",({list[[All,1]],90-list[[All,2]]}//Transpose)/.x_?NumberQ:>ToString[NumberForm[x,NumberPoint->","]],"Table"];

Additionally to changing the NumberPoint I want the entries to have only a single delimiter character between the columns list[[All,1]] and 90-list[[All,2]] in every line, i.e. a single spacebar or tab, to be able to import the data with another program.

The standard Export command however uses 4 times blank after padding every entry with blanks, which is an issue.

Thanks in advance and sorry for my lack of knowledge in formatting my questions properly!

ANewb
  • 77
  • 5

1 Answers1

2

I think this should work with Mathematica version 4 :

list=Table[Random[Real,90],{2}]&/@Range[6];

myRiffleForMma4[l_List,elt_String]:=Insert[l,elt,List /@ Range[2,Length[l]]]

Export["test00.txt",
       StringJoin[
           myRiffleForMma4[
              StringJoin[myRiffleForMma4[#," "]]& /@ Map[ToString,list,{2}],
              "|"]
               ],
       "String"]  

Mathematica 11.0 gives :

42.5872 74.261|86.0062 6.89626|75.0751 61.5735|44.216 83.7371|36.7864 2.49404|63.8472 36.3133

If you move to a newer Mathematica, you can replace myRiffleForMa4[] by the built-in function Riffle[] (introduced in version 6).

andre314
  • 18,474
  • 1
  • 36
  • 69
  • I may forget something that doesn't work with Mathematica 4. Please advice me. – andre314 Mar 01 '18 at 17:42
  • Hey @andre, thank you for your answer! Unfortunatelly, Export doesn't recognize "String" as a format in Mma4... however your code works pretty good with "Table" instead! Thanks alot! – ANewb Mar 06 '18 at 12:21