1
$\begingroup$

I have a large data set. Here is a part of it:

{1., 18.6, 460.4346}
{2., 28.4, 460.4346}
{3., 38.2, 460.4346}
{4., 48., 460.4346}

How to put a comma separator using mathematica command between the curly brackets so that it converts to table as follows: {{1., -28.6, 46.4346},{2., -28.4, 46.4346},{3., -28.2, 46.4346},{4., -28., 46.4346}}.

Here I put the commas by hand. Thanks

$\endgroup$
9
  • $\begingroup$ no, its the output of For[Print.....] $\endgroup$
    – SciJewel
    Commented Mar 10, 2023 at 0:59
  • $\begingroup$ the problem is that its too long and takes many hours to run. Even I provide the source, still need tailoring the data. $\endgroup$
    – SciJewel
    Commented Mar 10, 2023 at 6:20
  • $\begingroup$ If you are stuck with the output of For[Print ....] just cut the text out of the notebook, paste it into a text editor, edit it, then cut'n'paste back. ? $\endgroup$ Commented Mar 10, 2023 at 11:50
  • $\begingroup$ Its more than 2000 lines, hard to edit it in the editor. $\endgroup$
    – SciJewel
    Commented Mar 10, 2023 at 21:33
  • $\begingroup$ I copied to the editor and then imported. It now inserts commas, but now the data output in the form, "{1., 18.6, 460.4346}" "{2., 28.4, "460.4346"}" "{3., 38.2, "460.4346"}" "{4., 48., "460.4346"}" $\endgroup$
    – SciJewel
    Commented Mar 10, 2023 at 22:25

1 Answer 1

2
$\begingroup$

Copy paste data and save as txt file.

dnc = ReadList["C:/data_no_commas.txt"]
Map[Head, dnc, {2}]
Map[Head, dnc, {1}]

enter image description here

I agree with other comments that this should be natively generated.

$\endgroup$
5
  • $\begingroup$ I don't understand any purpose of this answer. All numbers are already real. $\endgroup$
    – SciJewel
    Commented Mar 11, 2023 at 16:26
  • $\begingroup$ This answer is an improvement over: I copied to the editor and then imported. It now inserts commas, but now the data output in the form, "{1., 18.6, 460.4346}" "{2., 28.4, "460.4346"}" "{3., 38.2, "460.4346"}" "{4., 48., "460.4346"}" $\endgroup$
    – Syed
    Commented Mar 11, 2023 at 16:42
  • $\begingroup$ I am already getting this, there is nothing new here. Do you know how to remove "..." from the curly brackets? $\endgroup$
    – SciJewel
    Commented Mar 11, 2023 at 17:49
  • $\begingroup$ You can start a new question about it. $\endgroup$
    – Syed
    Commented Mar 11, 2023 at 17:55
  • $\begingroup$ Look my comment above, I have already got this step before you suggested. If know the solution, please edit your answer. $\endgroup$
    – SciJewel
    Commented Mar 11, 2023 at 18:05

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.