Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I exported the result on NMinimize with .dat format. The data looks like:

enter image description here

Then I imported the data using:

Import["data.dat"];

The data in MMA looks like:

enter image description here

There are two (,) in the data shown in MMA. Now I cannot use this because when I use:

Mymodel[t] /. data[[2]]

The parameters in Mymodel won't take the values in data. How can I import my data properly and use it again? The parameter $\Delta$ after importing changes to nonsense, however in the dat file it's fine.

My data:

1.1719373597846176e6
Subscript[a, 1, 1] -> -39.07037581001687    Subscript[a, 1, 2] -> 32.839137392575736    Subscript[a, 1, 3] -> 47.04859760352587 Subscript[a, 1, 4] -> 85.54836344280284 Subscript[a, 1, 5] -> 89.3572784605761  Subscript[a, 1, 6] -> 112.72147714256346    Subscript[a, 1, 7] -> 141.1141100113585 Subscript[a, 1, 8] -> 161.5187350434043 Subscript[a, 1, 9] -> 175.7016855109587 Subscript[a, 1, 10] -> 171.55229014876858   Subscript[a, 1, 11] -> 154.25071538099695   Subscript[a, 1, 12] -> 125.05214808916814   Subscript[a, 1, 13] -> 100.80704192706914   Subscript[a, 1, 14] -> 64.08099482728616    Subscript[a, 1, 15] -> 33.038341794617224   Subscript[a, 1, 16] -> 9.569520817024989    Subscript[a, 1, 17] -> -16.266164560069445  Subscript[a, 1, 18] -> -28.891015617003045  Subscript[a, 1, 19] -> -35.31102040498092   Subscript[a, 1, 20] -> -34.82155634465738   Subscript[a, 1, 21] -> -26.40216271585209   Subscript[a, 1, 22] -> -22.137228450492998  Subscript[a, 1, 23] -> -19.939759086275554  Subscript[a, 1, 24] -> -4.529745755046207   Subscript[a, 2, 1] -> -8.262096251341937    Subscript[a, 2, 2] -> 39.93424658310768 Subscript[a, 2, 3] -> 59.17772856664775 Subscript[a, 2, 4] -> 85.11383147323797 Subscript[a, 2, 5] -> 103.73282166425444    Subscript[a, 2, 6] -> 130.11739931821623    Subscript[a, 2, 7] -> 152.23253250732932    Subscript[a, 2, 8] -> 175.64557869749953    Subscript[a, 2, 9] -> 201.14899323338128    Subscript[a, 2, 10] -> 198.63115865573573   Subscript[a, 2, 11] -> 185.72511180756692   Subscript[a, 2, 12] -> 161.4785551644416    Subscript[a, 2, 13] -> 118.62717529408515   Subscript[a, 2, 14] -> 82.79080925592181    Subscript[a, 2, 15] -> 49.50275889248166    Subscript[a, 2, 16] -> 26.751543115232693   Subscript[a, 2, 17] -> -2.903295814163817   Subscript[a, 2, 18] -> -15.706287304199819  Subscript[a, 2, 19] -> -26.95123031552248   Subscript[a, 2, 20] -> -16.55204465607971   Subscript[a, 2, 21] -> -15.63690068567017   Subscript[a, 2, 22] -> -18.445139467068348  Subscript[a, 2, 23] -> -12.659200223485469  Subscript[a, 2, 24] -> -5.962580128189138   Subscript[a, 3, 1] -> 37.444101946418606    Subscript[a, 3, 2] -> 23.21078669192909 Subscript[a, 3, 3] -> 35.80731556592555 Subscript[a, 3, 4] -> 49.50645735462091 Subscript[a, 3, 5] -> 69.65835497466128 Subscript[a, 3, 6] -> 90.05590337876777 Subscript[a, 3, 7] -> 107.54972407429175    Subscript[a, 3, 8] -> 134.58686959015793    Subscript[a, 3, 9] -> 152.62441781305003    Subscript[a, 3, 10] -> 165.1720495385376    Subscript[a, 3, 11] -> 162.84787173284377   Subscript[a, 3, 12] -> 150.95139348142118   Subscript[a, 3, 13] -> 137.0382860491445    Subscript[a, 3, 14] -> 133.65163910616894   Subscript[a, 3, 15] -> 131.81798473114085   Subscript[a, 3, 16] -> 133.75079745491237   Subscript[a, 3, 17] -> 143.23942955668883   Subscript[a, 3, 18] -> 141.56751697722737   Subscript[a, 3, 19] -> 132.28785624168043   Subscript[a, 3, 20] -> 113.36015200529705   Subscript[a, 3, 21] -> 86.37455010294536    Subscript[a, 3, 22] -> 65.42845023832571    Subscript[a, 3, 23] -> 46.312675399941256   Subscript[a, 3, 24] -> 27.932761709617406   Subscript[μ, 1] -> 69.64797135105368    Subscript[μ, 2] -> 137.44079092106227   Subscript[μ, 3] -> 137.16460450848953   Subscript[μ, 4] -> 136.99347697276175   Subscript[μ, 5] -> 136.86600458739028   Subscript[μ, 6] -> 137.66773316797602   Subscript[μ, 7] -> 138.71504826760085   Subscript[μ, 8] -> 137.86968038934324   Subscript[μ, 9] -> 139.59905621326638   Subscript[μ, 10] -> 140.25024135591553  Subscript[μ, 11] -> 140.2694453172227   Subscript[μ, 12] -> 140.25903056582487  Subscript[μ, 13] -> 140.76056107163038  Subscript[μ, 14] -> 140.57048134866926  Subscript[μ, 15] -> 141.2423932521736   Subscript[μ, 16] -> 142.58509714117514  Subscript[μ, 17] -> 142.51063755538405  Subscript[μ, 18] -> 143.13528607312404  Subscript[μ, 19] -> 142.18681058236535  Subscript[μ, 20] -> 143.6154398513785   Subscript[μ, 21] -> 142.91697372187775  Subscript[μ, 22] -> 136.6821951928868   Subscript[μ, 23] -> 130.45585729159586  Subscript[μ, 24] -> 139.79590440094432  Subscript[b, 1] -> 10.  Subscript[b, 2] -> 10.  Subscript[b, 3] -> 10.  Subscript[b, 4] -> 10.  Subscript[b, 5] -> 10.  Subscript[b, 6] -> 10.  Subscript[b, 7] -> 10.  Subscript[b, 8] -> 10.  Subscript[b, 9] -> 10.  Subscript[b, 10] -> 10. Subscript[b, 11] -> 10. Subscript[b, 12] -> 10. Subscript[b, 13] -> 10. Subscript[b, 14] -> 10. Subscript[b, 15] -> 10. Subscript[b, 16] -> 10. Subscript[b, 17] -> 10. Subscript[b, 18] -> 10. Subscript[b, 19] -> 10. Subscript[b, 20] -> 10. Subscript[b, 21] -> 10. Subscript[b, 22] -> 10. Subscript[b, 23] -> 10. Subscript[b, 24] -> 10. Δ -> 25.92287490310396  Subscript[τ, 1] -> 40.890610245193756   Subscript[τ, 2] -> 70.8818159449603 Subscript[τ, 3] -> 306.0431348497769
share|improve this question
    
You should provide a sample of your data/file for a better chance of getting assistance. –  RunnyKine Aug 18 at 21:26
    
I added the data. –  yashar Aug 18 at 21:38

4 Answers 4

up vote 3 down vote accepted

First I saved the data in a file named "data.dat" as Text, then I imported your data, including the Delta

data = Import[...]

then the trick:

data // ToExpression

and here are the data

{{1.171937359784618*10^6}, {Subscript[a, 1, 1] -> -39.07037581001687, 
  Subscript[a, 1, 2] -> 32.83913739257574, 
  Subscript[a, 1, 3] -> 47.04859760352587, 
  Subscript[a, 1, 4] -> 85.54836344280284, 
  Subscript[a, 1, 5] -> 89.3572784605761, 
  Subscript[a, 1, 6] -> 112.7214771425635, 
  Subscript[a, 1, 7] -> 141.1141100113585, 
  Subscript[a, 1, 8] -> 161.5187350434043, 
  Subscript[a, 1, 9] -> 175.7016855109587, 
  Subscript[a, 1, 10] -> 171.5522901487686, 
  Subscript[a, 1, 11] -> 154.250715380997, 
  Subscript[a, 1, 12] -> 125.0521480891681, 
  Subscript[a, 1, 13] -> 100.8070419270691, 
  Subscript[a, 1, 14] -> 64.08099482728616, 
  Subscript[a, 1, 15] -> 33.03834179461722, 
  Subscript[a, 1, 16] -> 9.569520817024989, 
  Subscript[a, 1, 17] -> -16.26616456006945, 
  Subscript[a, 1, 18] -> -28.89101561700305, 
  Subscript[a, 1, 19] -> -35.31102040498092, 
  Subscript[a, 1, 20] -> -34.82155634465738, 
  Subscript[a, 1, 21] -> -26.40216271585209, 
  Subscript[a, 1, 22] -> -22.137228450493, 
  Subscript[a, 1, 23] -> -19.93975908627555, 
  Subscript[a, 1, 24] -> -4.529745755046207, 
  Subscript[a, 2, 1] -> -8.262096251341937, 
  Subscript[a, 2, 2] -> 39.93424658310768, 
  Subscript[a, 2, 3] -> 59.17772856664775, 
  Subscript[a, 2, 4] -> 85.11383147323797, 
  Subscript[a, 2, 5] -> 103.7328216642544, 
  Subscript[a, 2, 6] -> 130.1173993182162, 
  Subscript[a, 2, 7] -> 152.2325325073293, 
  Subscript[a, 2, 8] -> 175.6455786974995, 
  Subscript[a, 2, 9] -> 201.1489932333813, 
  Subscript[a, 2, 10] -> 198.6311586557357, 
  Subscript[a, 2, 11] -> 185.7251118075669, 
  Subscript[a, 2, 12] -> 161.4785551644416, 
  Subscript[a, 2, 13] -> 118.6271752940852, 
  Subscript[a, 2, 14] -> 82.79080925592181, 
  Subscript[a, 2, 15] -> 49.50275889248166, 
  Subscript[a, 2, 16] -> 26.75154311523269, 
  Subscript[a, 2, 17] -> -2.903295814163817, 
  Subscript[a, 2, 18] -> -15.70628730419982, 
  Subscript[a, 2, 19] -> -26.95123031552248, 
  Subscript[a, 2, 20] -> -16.55204465607971, 
  Subscript[a, 2, 21] -> -15.63690068567017, 
  Subscript[a, 2, 22] -> -18.44513946706835, 
  Subscript[a, 2, 23] -> -12.65920022348547, 
  Subscript[a, 2, 24] -> -5.962580128189138, 
  Subscript[a, 3, 1] -> 37.44410194641861, 
  Subscript[a, 3, 2] -> 23.21078669192909, 
  Subscript[a, 3, 3] -> 35.80731556592555, 
  Subscript[a, 3, 4] -> 49.50645735462091, 
  Subscript[a, 3, 5] -> 69.65835497466128, 
  Subscript[a, 3, 6] -> 90.05590337876777, 
  Subscript[a, 3, 7] -> 107.5497240742918, 
  Subscript[a, 3, 8] -> 134.5868695901579, 
  Subscript[a, 3, 9] -> 152.62441781305, 
  Subscript[a, 3, 10] -> 165.1720495385376, 
  Subscript[a, 3, 11] -> 162.8478717328438, 
  Subscript[a, 3, 12] -> 150.9513934814212, 
  Subscript[a, 3, 13] -> 137.0382860491445, 
  Subscript[a, 3, 14] -> 133.6516391061689, 
  Subscript[a, 3, 15] -> 131.8179847311409, 
  Subscript[a, 3, 16] -> 133.7507974549124, 
  Subscript[a, 3, 17] -> 143.2394295566888, 
  Subscript[a, 3, 18] -> 141.5675169772274, 
  Subscript[a, 3, 19] -> 132.2878562416804, 
  Subscript[a, 3, 20] -> 113.3601520052971, 
  Subscript[a, 3, 21] -> 86.37455010294536, 
  Subscript[a, 3, 22] -> 65.42845023832571, 
  Subscript[a, 3, 23] -> 46.31267539994126, 
  Subscript[a, 3, 24] -> 27.93276170961741, 
  Subscript[\[Mu], 1] -> 69.64797135105368, 
  Subscript[\[Mu], 2] -> 137.4407909210623, 
  Subscript[\[Mu], 3] -> 137.1646045084895, 
  Subscript[\[Mu], 4] -> 136.9934769727618, 
  Subscript[\[Mu], 5] -> 136.8660045873903, 
  Subscript[\[Mu], 6] -> 137.667733167976, 
  Subscript[\[Mu], 7] -> 138.7150482676009, 
  Subscript[\[Mu], 8] -> 137.8696803893432, 
  Subscript[\[Mu], 9] -> 139.5990562132664, 
  Subscript[\[Mu], 10] -> 140.2502413559155, 
  Subscript[\[Mu], 11] -> 140.2694453172227, 
  Subscript[\[Mu], 12] -> 140.2590305658249, 
  Subscript[\[Mu], 13] -> 140.7605610716304, 
  Subscript[\[Mu], 14] -> 140.5704813486693, 
  Subscript[\[Mu], 15] -> 141.2423932521736, 
  Subscript[\[Mu], 16] -> 142.5850971411751, 
  Subscript[\[Mu], 17] -> 142.5106375553841, 
  Subscript[\[Mu], 18] -> 143.135286073124, 
  Subscript[\[Mu], 19] -> 142.1868105823654, 
  Subscript[\[Mu], 20] -> 143.6154398513785, 
  Subscript[\[Mu], 21] -> 142.9169737218778, 
  Subscript[\[Mu], 22] -> 136.6821951928868, 
  Subscript[\[Mu], 23] -> 130.4558572915959, 
  Subscript[\[Mu], 24] -> 139.7959044009443, Subscript[b, 1] -> 10., 
  Subscript[b, 2] -> 10., Subscript[b, 3] -> 10., 
  Subscript[b, 4] -> 10., Subscript[b, 5] -> 10., 
  Subscript[b, 6] -> 10., Subscript[b, 7] -> 10., 
  Subscript[b, 8] -> 10., Subscript[b, 9] -> 10., 
  Subscript[b, 10] -> 10., Subscript[b, 11] -> 10., 
  Subscript[b, 12] -> 10., Subscript[b, 13] -> 10., 
  Subscript[b, 14] -> 10., Subscript[b, 15] -> 10., 
  Subscript[b, 16] -> 10., Subscript[b, 17] -> 10., 
  Subscript[b, 18] -> 10., Subscript[b, 19] -> 10., 
  Subscript[b, 20] -> 10., Subscript[b, 21] -> 10., 
  Subscript[b, 22] -> 10., Subscript[b, 23] -> 10., 
  Subscript[b, 24] -> 10., \[CapitalDelta] -> 25.92287490310396, 
  Subscript[\[Tau], 1] -> 40.89061024519376, 
  Subscript[\[Tau], 2] -> 70.8818159449603, 
  Subscript[\[Tau], 3] -> 306.0431348497769}}

Hope it works for you too

share|improve this answer

The best way to export your data and import it again is to use the WDX data format. Wolfram Language Documentation Center - WDX Data Format

It allows for platform independent storing and exchange of information and data.

Example

Export["solve.wdx", 
 Solve[7 Subscript[a, 1, 1] + 5 Subscript[a, 1, 2] == 17 && 
   2 Subscript[a, 1, 1] + 3 Subscript[a, 1, 2] == 8, {Subscript[a, 1, 
   1], Subscript[a, 1, 2]}]]
rules = Flatten@Import["solve.wdx"]
(17 Subscript[a, 1, 1] + 5 Subscript[a, 1, 2]) /. rules
(*27*)

UPDATE

Now, in the specific case that it was exported in .dat, for this specific example above.

Export["solve.dat", 
 Solve[7 Subscript[a, 1, 1] + 5 Subscript[a, 1, 2] == 17 && 
   2 Subscript[a, 1, 1] + 3 Subscript[a, 1, 2] == 8, {Subscript[a, 1, 
    1], Subscript[a, 1, 2]}]];
vals = Import["solve.dat"];
index = Flatten@Position[vals[[1]], "->"];
Rule[ToExpression[StringJoin@vals[[1, # - 3 ;; # - 1]]], 
   vals[[1, # + 1]]] & /@ index
share|improve this answer
    
I have already imported in dat format. What can I do fr that? –  yashar Aug 18 at 21:46

At this point I think it is probably best to import your data as a plain string and then extract your Rules using StringCases:

text = Import["odd.dat", "Text"];

StringCases[text, 
 x : Shortest["Subscript[" ~~ __ ~~ "] -> " ~~ NumberString] :> ToExpression[x]]
{Subscript[a, 1, 1] -> -39.0704, Subscript[a, 1, 2] -> 32.8391, 
 Subscript[a, 1, 3] -> 47.0486, Subscript[a, 1, 4] -> 85.5484, 
 Subscript[a, 1, 5] -> 89.3573, Subscript[a, 1, 6] -> 112.721, 
 Subscript[a, 1, 7] -> 141.114, Subscript[a, 1, 8] -> 161.519, 
 Subscript[a, 1, 9] -> 175.702, ..., Subscript[τ, 3] -> 306.043}

You may need to set the CharacterEncoding option for Import so that your text data is read correctly.

share|improve this answer

why not modifying the data originally before exporting it.

you may do something like this:

data2 = List @@ data /. Rule -> Sequence /. Times -> List;
sub = Join[{data2[[1]]}, data2[[2 ;; -2, 2]]];
numb = Join[data2[[2 ;; -2, 1]], {data2[[-1]]}];

and now if you want to export the data as list you can do it like this:

Export["dat.dat",Transpose{sub,numb}]

and you can make rule using any way like

Rule @@@ Transpose[{sub, numb}]

or

Thread[sub -> numb]
share|improve this answer
    
I suspect the OP only has the exported data and is trying to recover it. I don't think he is planning to export to that format on an ongoing basis. –  Mr.Wizard Aug 19 at 0:09
    
It could be, especially he provided that data in MMA format and he said also he exported that data himself. but your answer would solve the issue if OP only has exported data. –  Algohi Aug 19 at 0:14
    
Can you explain me the abbreviation OP ? –  hieron Aug 19 at 22:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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