Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15233 > unrolled thread

Re: Writing numeric data to CSV does not write final EOL

Started bySseziwa Mukasa <mukasa@gmail.com>
First post2013-07-23 08:42 +0000
Last post2013-09-24 07:58 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Writing numeric data to CSV does not write final EOL Sseziwa Mukasa <mukasa@gmail.com> - 2013-07-23 08:42 +0000
    Re: Writing numeric data to CSV does not write final EOL Alan <alan.isaac@gmail.com> - 2013-09-17 09:31 +0000
    Re: Writing numeric data to CSV does not write final EOL Sseziwa Mukasa <mukasa@gmail.com> - 2013-09-19 05:19 +0000
      Re: Writing numeric data to CSV does not write final EOL David Bailey <dave@removedbailey.co.uk> - 2013-09-24 07:58 +0000

#15233 — Re: Writing numeric data to CSV does not write final EOL

FromSseziwa Mukasa <mukasa@gmail.com>
Date2013-07-23 08:42 +0000
SubjectRe: Writing numeric data to CSV does not write final EOL
Message-ID<kslfm0$pnu$1@smc.vnet.net>
You can append an empty row:

Export["C:/tmpfile.csv", Append[mytable,{}], "csv"];

On Jul 21, 2013, at 4:22 AM, kogan.clark@gmail.com wrote:

> Hi!
>
> I am using Mathematica 8 to write a numeric matrix to a csv file using the commands:
>
> mytable = {{1, 2}, {3, 4}};
> mytable = Export["C:/tmpfile.csv", mytable, "csv"];
>
>
> This produces a file, but does not put a final line end character after the 4. I am trying to read this file with R, which requires the final line end character. I was wondering if anyone knew the simplest (or a very simple) way to add the additional line end character.
>
> Thanks!
>
> Clark
>

[toc] | [next] | [standalone]


#15459

FromAlan <alan.isaac@gmail.com>
Date2013-09-17 09:31 +0000
Message-ID<l197go$97o$1@smc.vnet.net>
In reply to#15233
On Tuesday, July 23, 2013 4:42:40 AM UTC-4, Sseziwa Mukasa wrote:
> Export["C:/tmpfile.csv", Append[mytable,{}], "csv"];


If ``mytable`` is huge, won't this require the temporary creation of another huge list?

Alan Isaac

[toc] | [prev] | [next] | [standalone]


#15475

FromSseziwa Mukasa <mukasa@gmail.com>
Date2013-09-19 05:19 +0000
Message-ID<l1e1g6$l2t$1@smc.vnet.net>
In reply to#15233
You're right, this will make a temporary copy of the list.  Alternatively, export the table:

Export["C:/tmpfile.csv",mytable];

then:

fileStream=OpenAppend["C:/tmpfile.csv"];
WriteString[fileStream,"\n"]
Close[fileStream];

Regards,
Sseziwa

On Sep 17, 2013, at 9:34 PM, Alan <alan.isaac@gmail.com> wrote:

> On Tuesday, July 23, 2013 4:42:40 AM UTC-4, Sseziwa Mukasa wrote:
>> Export["C:/tmpfile.csv", Append[mytable,{}], "csv"];
>
>
> If ``mytable`` is huge, won't this require the temporary creation of another huge list?
>
> Alan Isaac
>

[toc] | [prev] | [next] | [standalone]


#15526

FromDavid Bailey <dave@removedbailey.co.uk>
Date2013-09-24 07:58 +0000
Message-ID<l1rgno$q2u$1@smc.vnet.net>
In reply to#15475
On 19/09/2013 06:19, Sseziwa Mukasa wrote:
 > You're right, this will make a temporary copy of the list. 
Alternatively, export the table:
 >

Mathematica seems to keep track of which parts of an expression have 
been altered, so my guess is that all the sublists would not be copied. 
Therefore the cost would be fairly small - I would take this approach 
first, and possibly time it to determine if it is more costly than 
performing the original Export.

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web