2
$\begingroup$

I've imported a large data set, manually removing headers in the .rtf file where it originates. However, when I import this data, I receive this output:

data = Import["//pathtofile//data.rtf"]
Notebook[{Cell["1   3.32    10  10  10  670 600 1
           2    2.26    6   8   5   700 640 1
           3    2.35    8   6   8   640 530 1
           4    2.08    9   10  7   670 600 1
           5    3.38    8   9   8   540 580 1
           6    3.29    10  8   8   760 630 1
           7    3.21    8   8   7   600 400 1
           8    2.00    3   7   6   460 530 1
           9    3.18    9   10  8   670 450 1
          10    2.34    7   7   6   570 480 1
          11    3.08    9   10  6   491 488 1
          12    3.34    5   9   7   600 600 1
          13    1.40    6   8   8   510 530 1
          14    1.43    10  9   9   750 610 1
          15    2.48    8   9   6   650 460 1
          16    3.73    10  10  9   720 630 1
          17    3.80    10  10  9   760 500 1
          18    4.00    9   9   8   800 610 1
          19    2.00    9   6   5   640 670 1
          20    3.74    9   10  9   750 700 1
          21    2.32    9   7   8   520 440 1
          22    2.79    8   8   7   610 530 1
          23    3.21    7   9   8   505 435 1
          24    3.08    9   10  8   559 607 1
          25    3.75    10  9   9   760 620 1
          26    3.16    10  9   8   640 490 1
          27    2.73    9   8   7   520 360 1
          28    3.06    8   10  10  580 460 1
          29    1.07    7   8   6   700 520 1
          30    3.35    10  10  10  620 570 1
          31    1.82    6   8   6   490 550 1
          32    3.12    10  10  7   640 520 1
          33    2.25    9   7   4   550 290 1
          34    2.93    10  10  10  600 520 1
          35    3.16    9   7   7   400 390 1
          36    2.83    10  9   9   710 530 1
          37    3.10    9   10  9   750 670 1
          38    3.07    7   4   7   660 480 1
          39    2.87    9   9   9   620 480 1
          40    3.61    10  10  9   630 440 1
          41    2.17    10  7   7   650 450 1
          42    1.95    7   8   9   550 570 1
          43    3.35    10  10  10  730 650 1
          44    3.58    10  7   8   710 400 1
          45    2.75    10  7   5   770 720 1
          46    3.26    10  10  9   610 560 1
          47    3.41    9   4   7   600 360 1
          48    3.67    10  10  10  640 570 1
          49    3.81    10  10  7   750 540 1
          50    3.30    10  10  9   650 480 1
          51    2.30    9   10  10  590 420 1
          52    3.62    10  10  8   660 630 1
          53    3.20    9   5   7   570 570 1
          54    2.55    7   8   8   570 480 1
          55    2.82    10  9   9   660 550 1
          56    3.25    9   7   8   690 550 1
          57    2.21    7   7   8   670 500 1
          58    2.50    10  9   9   660 460 1
          59    3.03    8   8   7   600 630 1
          60    1.92    9   10  8   447 320 1
          61    4.00    7   6   6   600 410 1
          62    1.81    9   9   9   620 580 1
          63    2.70    6   8   6   580 470 1
          64    2.96    9   7   8   630 630 1
          65    2.76    10  10  10  600 560 1
          66    2.71    8   7   9   700 440 1
          67    3.40    9   10  9   550 560 1
          68    2.65    8   10  8   680 450 1
          69    2.48    8   8   7   630 500 1
          70    3.86    10  10  10  750 760 1
          71    2.62    9   8   7   491 391 1
          72    3.72    7   8   7   550 500 1
          73    3.50    8   7   8   630 500 1
          74    2.83    6   7   7   690 440 1
          75    3.06    8   6   5   540 400 1
          76    4.00    9   10  10  640 480 1
          77    3.70    8   10  8   520 410 1
          78    2.81    9   7   4   559 488 1
          79    1.93    8   6   8   590 510 1
          80    3.70    10  10  10  580 580 1
          81    2.96    9   7   6   670 440 1
          82    2.64    9   9   8   620 590 1
          83    3.09    10  10  8   540 470 1
          84    3.00    4   3   4   620 560 1
          85    2.97    10  10  10  770 540 1
          86    2.81    10  10  10  620 570 1
          87    3.32    10  9   10  660 560 1
          88    3.40    7   8   4   710 500 1
          89    1.84    9   6   6   610 390 1
          90    0.40    6   6   7   560 690 1
          91    2.88    9   7   6   690 460 1
          92    2.77    6   5   9   590 440 1
          93    2.26    5   7   7   530 440 1
          94    2.03    6   7   9   540 610 1
          95    2.43    7   10  10  530 560 1
          96    2.63    10  10  6   640 500 1
          97    1.66    8   4   3   590 470 1
          98    3.41    9   9   9   520 490 1
          99    2.12    7   7   8   559 545 1
         100    3.33    7   6   7   500 460 1
         101    1.69    8   7   7   490 390 1
         102    2.46    6   7   7   490 370 1
         103    1.59    8   9   7   670 480 1
         104    1.14    10  10  7   720 610 1
         105    0.65    9   7   7   640 520 1
         106    2.12    7   6   7   520 380 1
         107    2.82    4   5   7   400 470 1
         108    2.34    8   9   7   480 410 1
         109    2.11    6   9   9   480 390 1
         110    1.34    6   7   8   530 470 1
         111    2.53    8   9   8   550 500 1
         112    2.75    10  10  10  720 500 1
         113    3.14    9   8   9   640 630 1
         114    2.25    10  10  10  690 580 1
         115    1.00    8   9   10  640 600 1
         116    2.79    9   6   7   690 400 1
         117    2.39    6   5   6   470 330 1
         118    2.15    6   6   6   480 460 1
         119    0.75    7   6   6   540 590 1
         120    3.06    5   9   9   510 380 1
         121    2.50    9   9   9   560 500 1
         122    2.78    9   9   10  600 510 1
         123    2.44    8   8   8   690 490 1
         124    1.11    7   7   7   590 480 1
         125    3.12    10  10  10  580 340 1
         126    2.17    8   7   8   650 500 1
         127    0.12    4   6   6   630 490 1
         128    2.00    6   5   6   530 320 1
         129    3.22    9   7   9   650 490 1
         130    1.88    10  6   6   620 430 1
         131    2.04    8   7   7   690 440 1
         132    2.58    10  9   9   720 740 1
         133    2.16    6   6   6   590 440 1
         134    2.50    7   10  10  630 500 1
         135    1.85    10  8   7   700 480 1
         136    1.46    7   7   8   630 540 1
         137    2.95    9   9   8   620 400 1
         138    0.80    8   10  9   470 410 1
         139    0.91    6   5   7   586 697 1
         140    2.67    9   9   10  586 670 1
         141    2.51    9   8   7   700 500 1
         142    1.79    7   7   5   550 570 1
         143    2.42    6   6   8   505 518 1
         144    0.58    5   7   7   515 285 1
         145    3.00    10  10  9   774 688 1
         146    2.76    10  10  10  570 570 0
         147    3.35    9   9   9   580 540 0
         148    3.80    10  9   8   560 530 0
         149    2.38    9   9   10  650 570 0
         150    2.58    10  10  9   440 430 0
         151    3.18    10  10  10  570 750 0
         152    2.87    8   8   7   476 576 0
         153    3.16    8   9   8   680 700 0
         154    3.07    9   8   9   490 480 0
         155    3.68    10  8   9   590 490 0
         156    3.34    10  9   10  590 580 0
         157    1.93    10  8   8   650 490 0
         158    2.43    9   5   9   480 520 0
         159    3.28    10  10  10  670 490 0
         160    3.66    10  10  10  710 600 0
         161    2.29    7   6   8   570 570 0
         162    2.19    6   5   6   540 460 0
         163    3.06    10  10  10  620 510 0
         164    3.41    8   6   8   630 470 0
         165    3.14    9   9   10  630 700 0
         166    2.85    10  8   8   610 460 0
         167    3.47    10  10  9   720 680 0
         168    3.44    10  10  9   640 590 0
         169    3.90    10  10  10  650 500 0
         170    3.65    9   9   9   640 430 0
         171    1.32    9   8   9   740 460 0
         172    3.23    10  10  10  600 660 0
         173    2.86    10  9   10  650 430 0
         174    2.51    8   9   10  510 440 0
         175    2.86    8   9   8   550 510 0
         176    3.34    10  9   9   570 530 0
         177    3.33    9   7   9   630 560 0
         178    3.69    10  10  8   710 470 0
         179    1.80    7   7   7   620 470 0
         180    2.57    9   10  10  417 518 0
         181    2.28    8   10  10  600 600 0
         182    1.60    4   7   7   460 460 0
         183    2.00    2   4   6   300 290 0
         184    1.69    7   6   7   560 480 0
         185    3.06    9   10  9   590 420 0
         186    2.75    8   9   8   559 435 0
         187    2.62    9   10  8   550 440 0
         188    0.39    7   10  9   550 660 0
         189    2.44    10  9   9   650 350 0
         190    3.46    9   9   8   610 520 0
         191    2.37    8   7   9   530 480 0
         192    1.25    7   8   6   480 360 0
         193    2.80    10  9   9   550 450 0
         194    2.14    5   4   8   560 420 0
         195    2.45    7   7   8   430 330 0
         196    2.71    9   7   10  490 400 0
         197    2.59    10  10  10  590 470 0
         198    2.93    9   9   10  690 510 0
         199    2.53    7   6   9   570 480 0
         200    1.95    6   6   9   550 600 0
         201    3.39    9   9   10  510 570 0
         202    2.69    8   6   9   470 420 0
         203    1.94    8   8   8   470 330 0
         204    3.00    10  8   9   510 360 0
         205    2.09    9   7   8   450 460 0
         206    1.85    10  8   10  530 550 0
         207    3.34    10  9   10  490 410 0
         208    2.25    6   9   10  530 510 0
         209    4.00    10  10  10  580 490 0
         210    2.72    6   5   7   580 490 0
         211    2.61    9   7   8   620 420 0
         212    2.32    6   6   7   430 460 0
         213    3.39    10  10  10  500 390 0
         214    3.64    8   6   8   590 580 0
         215    1.80    8   7   9   620 600 0
         216    1.52    9   9   10  520 570 0
         217    3.40    6   9   9   480 480 0
         218    2.86    9   4   8   640 470 0
         219    3.32    10  9   10  640 560 0
         220    2.07    9   7   6   600 440 0
         221    0.85    7   7   9   510 480 0
         222    1.86    7   9   7   356 350 0
         223    2.59    5   4   7   630 470 0
         224    2.28    9   8   9   559 488 0
   ", "Input", CharacterEncoding -> "MacintoshRoman"]}, 
 WindowSize -> {740, 597}, 
 WindowMargins -> {{270, Automatic}, {Automatic, 50}}, 
 FrontEndVersion -> 
  "9.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (January 25, 2013)", 
 StyleDefinitions -> "Default.nb"]

And I'm not sure what to do; I'm pretty new to Mathematica. I've made numerous attempts to remove the cases at the end using the DeleteCases function,

DeleteCases[data,{_String},{-2}];

As well as, using the Flatten function. My thought is that the reason they can't be deleted in this way is because they're a part of a larger cell than what I've specified, but I'm not sure how to correct this. I can't begin data analysis with these elements at the end of the table.

$\endgroup$
1
$\begingroup$
data2= StringSplit /@ StringSplit[Cases[data, Cell[t_, "Input", ___] :> t, Infinity], "\n"]

gives

enter image description here

You can convert the strings to numbers using

ToExpression/@data2
$\endgroup$
  • $\begingroup$ ah this takes care of the problem. Thank you! $\endgroup$ – Lame-Ov2.0 Dec 2 '14 at 21:30
  • $\begingroup$ @Lame-Ov2.0, may pleasure. Welcome to mma.se. $\endgroup$ – kglr Dec 2 '14 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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