MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: exporting numerical data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106711] Re: exporting numerical data
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 21 Jan 2010 04:56:46 -0500 (EST)

On 1/20/10 at 6:46 AM, shinytinkerbell at googlemail.com wrote:

>I have the following problem: I've created a table in mathematica
>that looks like this: TabIntegral={
>{{m_1,k_1,F(m_1,k_1)},{m_1,k_2,F(m_1,k_2)},...
>{m_1,k_N,...,F(m_1,k_N)}} , {{m_2,k_1,F(m_2,k_1)},{m_2,k_2,F
>(m_2,k_2)},...,{m_2,k_N,F(m_2,k_N)}} , ... , {{m_N,k_1,F(m_N,k_1)},
>{m_N,k_2,F(m_N,k_2)},...,{m_N,k_N,F(m_N,k_N)}} }; So something like
>an array of {x,y,F(x,y)} records. Now, I'd like to save this in
>human readable form in a file in such a way that I'd have three
>columns:

>m_1   k_1  F(m_1,k_1)
>m_1   k_2  F(m_1,k_2)
>...
>m_1   k_N  F(m_1,k_N)
>m_2   k_1  F(m_2,k_1)
>...
>m_2   k_N  F(m_2,k_N)
>...
>m_N   k_N  F(m_N,k_N)

>I've tried like that: Export["TabIntegral.dat", TabIntegral,
>"Table"]

Try Export["TabIntegral.dat", TabIntegral, "TSV"] instead

>The second question would be the following: as you see I have in my
>file small numbers such like 5.6073615530027356*^-9 that I'd like to
>read later on with a C-written program. If I'll leave it in this
>format as it is, there's no way C-program can read that. So how to
>write/format such small numbers while exporting to guarantee that
>I'll be able to C-read them later?

Use CForm. For example,

=46irst, I generate some data guaranteed to have a mix of small an
large values

data = Partition[Riffle[RandomReal[1, {6}], RandomReal[10^-9, {6}]],
    3];

Then I write it to a file using:

Export["test", Map[CForm, data, {2}], "TSV"];

And the result copied from the file is:

0.5301071393681702  6.926079257776034e-11   0.530905760511476
8.362980091084562e-10   0.9676815104585867  4.1382735679317465e-10
0.3921371716712816  5.082457555494514e-10   0.007833160315384058
7.548468366279675e-10   0.43235469921728775 1.483762786846197e-11



  • Prev by Date: Re: Sorting paired columns of dates and values
  • Next by Date: Re: Re: Replace list element based on a condition how to
  • Previous by thread: Re: exporting numerical data
  • Next by thread: Full Screen