4
$\begingroup$

When using the desktop version of Mathematica, I can copy text from other applications (specifically, a block of data in a spreadsheet) and paste into Mathematica between " " and be asked if I want to escape special characters. This is a fast way of importing from Excel, as explained in this post.

That doesn't seem to work on Mathematica Online - escape characters aren't added. (In the case of importing data from a spreadsheet following the link above, the input of ImportString["","TSV"] adds multiplication symbols x between numbers, giving the appearance they will all be multiplied. However, when that cell is evaluated, the data is imported as a list of 1 list. This can easily be partitioned into a matrix, but the point is skip that extra step.)

Is there a way to get Mathematica Online to add escape characters?

$\endgroup$

1 Answer 1

2
$\begingroup$

One way is to paste it in anyway and fix it up later. For example. Define a function that takes the input string and then turns it into a matrix.

toMatrix[str_, cols_] := Partition[Interpreter[
   DelimitedSequence[Number]][StringReplace[str,
   "\t" -> ","]], cols];

Now, in your browser you type this into a cell

toMatrix[" ",2]

and paste into the " " and where you replace 2 with the number of columns. This may seem similar to what you already use, but maybe someone else has a better answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.