Error in ExportString[list,"TSV"]?
- To: mathgroup at smc.vnet.net
- Subject: [mg125163] Error in ExportString[list,"TSV"]?
- From: "Alexey Popkov" <lehin.p at gmail.com>
- Date: Sat, 25 Feb 2012 01:56:45 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hello, Consider the following: In[29]:= ExportString[{{1},{2}},"TSV"] %//InputForm Out[29]= 1 2 Out[30]//InputForm= "1\r\n2" One can see that the resulting String expression contains two line breaks because it has two "newline" characters "\r" and "\n" instead of one character "\n". This is because the temporary file is readed backward with the option BinaryFormat->True: In[34]:= Cases[Trace@ExportString[{{1},{2}},"TSV"],e_OpenRead:>HoldForm[e],Infinity]//Last Out[34]= OpenRead[C:\WINDOWS\Temp\m-dad7b158-e2f5-4e25-9b27-da1f483eb68a,BinaryFormat->True] The documentation says that BinaryFormat->True "specifies that a stream should be opened in binary format, so that no textual interpretation of newlines or other data is done." But the TSV format is a textual, not binary format! I am using CopyToClipboard@Cell[ExportString[2Dlist, "TSV"]] for copying 2D lists of real values from Mathematica and pasting them to an Excel spreadsheet. But the contents of clipboard differs from the one generated by Exporting 2Dlist to a TSV text file and then copying its contents to clipboard via Notepad (the latter does not add unnecessary line breaks)! I think this is at least an inconsistency, it not it?