Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131679] Re: Writing numeric data to CSV does not write final EOL
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Fri, 20 Sep 2013 07:07:57 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <ksg5i0$c0v$1@smc.vnet.net>

Am Sonntag, 21. Juli 2013 10:19:12 UTC+2 schrieb Clark Kogan:
> 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

After correcting the commands for Windows

mytable = {{1, 2}, {3, 4}};
mytable = Export["C:\\temp\\tmpfile.csv", mytable, "csv"];

this works fine.

I can open the csv in Excel, or in Notepad, without problems although, as you said, the Hexdump Shows the Content 312C 320D 0A33 2C34, i.e. without a final 0D0A.

But, if you wish you can easily achieve what you want by appending an empty list, like this

mytableEOF = {{1, 2}, {3, 4},{}};

Best regards,
Wolfgang



  • Prev by Date: plotting integrals
  • Next by Date: Re: Quantity
  • Previous by thread: Re: Writing numeric data to CSV does not write final EOL
  • Next by thread: R: ReplacePart -> eliminate