r - Extracting Data from a file which is on a different line from key words -


Text after "

This is part of a file,

  Giao Chemical Preservation Tensor (PPM): Synthetic XYZ shielding (Anisotropy) 1 CX 192.9847 -0.3288 0.5647 y 0.8908 133.5254 1.9987 Z -1,5286 1,9986 131,2590 152,5897 EIGENVALS: 192,9663 130,1130 134,6898 (60,5649) OX 2 293.7037 -11.3068 19.4099 Wi -27.8836 337.6867 -38.0711 Z 47,8680 -38,0711 380,8636 337,4180 EIGENVALS: 283.3105 413.4345 315.50 9 1 (114.0247) 3 Acaks 32.4132 -2.6310 -3.6171 -0.9732 Y 26.6 9 66 2.2004 Z -1.6244 2.2423 28.7795 29.2 9 64 EIGENVALS: 34.4129 28.1896 25.2868 (7.6748) 4 Acaks 32.4132 4.4443 0.5044 y 1.8931 30.178 0.2675 9 Z 0.0452 0.2257 25.2 970 29.2 9 64 Aa EGNewes: 34.4129 28.1895 25.2867 (7.6748) 5 HX 31.3212 -2.3074 3.9610 Y-1.0235 26.9345 -1.8682 Z. 1.7569 -1.8682 29.0533 29.1030 EIGENVALS: 33.8408 27.6219 25.8462 (7.1067) 6 HX 32.4086 -3.5167 6.0369 Y-2.5502 27.9731 -8.1180 Jade 4.3777 -8.1180 37.1798 32.5205 EIGENVALS: 29.5456 44.7719 23.2441 (18.3770) ..... NMR with Shildings .....  

I'm interested in the data between the lines, "Giao chemical preservation

> 1C 152.5897 60.5649 2O 337.4180 114.0247 3H 29.2964 7.6748 4H 29.2964 7.6748 5H 29 The .1030 7.1067 6H 32.5205 18.3770

But I have other files of this nature I do ou do not know start properly, I readLines to bring in files (R) Can I use, but after that ...?

Here is a link to the file, rather than just scrapping it. Some answers that work on small, scrap editions do not work on 'full file'. Read in the file

, remove lines that start with a (potentially empty) empty space And opens the open legs after one point. Then in the second row, paste the first 3 letters and letters of each of these lines 58-68 and remove all the spaces: part of extracting the # extract of the file between IX [1] and ix [2] L: / P>

  & lt; - readLines ("myfile.dat") ix & lt; - Grape ("Giao Chemical preservation tensor | NmR shielding with", L) L0 & lt; - L [seq (z [1] +1, w [2] -1)] # extract areas g < - Grep ("^ [([*] * \\ d", L0, value = TRUE) -   

"" 114.024 "" 3H "[8]" 29.296 "" 7.674 "" 4H "" 29.296 "" 7.674 "" 5H "" 29.103 "[15]" 7.106 "" 6H "" 32.520 "" 18.377 "

Gives it to the above version, but you also want to reshape a matrix,

  m> - Matrix (Res, Ncol = 3, byrow = TRUE)  

or data.frame,

  data.frame (v1 = m [, 1], v2 = as. Numeric (m [, 2]), v3 = as.numeric (m [, 3]))  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -