I'm very new to Mathematica. I want to use it as a data source for gnuplot (I know Mathematica can plot too), it uses a file format with data in columns and a space between each column on each row. Like this:
x y
1 123
2 234
4 456
etc.
I've come as far as to create this expression:
{CountryData["G8"], CountryData[#, "GDP"] & /@ CountryData["G8"]} // Transpose // Grid
This creates a table just like I want it. Now, how can I export this to a file not as matrix but as a table like it appears in Mathematica?
Your CountryData
usage can be streamlined a bit using the map operator /@
:
{#, CountryData[#, "GDP"]} & /@ CountryData["G8"],
Combining this with Export
you get this:
Export[
"C:\\Users\\Sjoerd\\Desktop\\tabel.txt",
{#, CountryData[#, "GDP"]} & /@ CountryData["G8"],
"Table",
"FieldSeparators" -> " "
]
Replace the above file path with something appropriate for your situation.