4
$\begingroup$

I need the numerical values from pdf files like this one.

Mathematica graphics

When I use the usual Import command, the PDF imports, but pages of images. How can Mathematica be used to import the numerical values from a PDF?

$\endgroup$
5
  • $\begingroup$ It is very likely the numbers are rasterized in your PDF. In that case, Import alone won't cut it. Maybe run the PDF through Google Docs to extract the text. $\endgroup$
    – m_goldberg
    Commented Jul 16, 2013 at 20:50
  • 2
    $\begingroup$ Take a look at mathematica.stackexchange.com/q/18683/193 $\endgroup$ Commented Jul 16, 2013 at 20:50
  • $\begingroup$ @m_goldberg That doesn't seem to be the case here. $\endgroup$ Commented Jul 16, 2013 at 20:55
  • $\begingroup$ @belisarius neat trick, alas it produces the error "Expecting an image or graphics instead". Checking the pdf file in Acrobat pro shows that these values are editable and so I should be able to import them. $\endgroup$ Commented Jul 16, 2013 at 21:06
  • $\begingroup$ the values seem to be in binary (??) Import["/pathto/SoLux Spectral Data.xls.pdf", "Plaintext"] $\endgroup$ Commented Jul 16, 2013 at 21:29

1 Answer 1

7
$\begingroup$

Using Adobe Acrobat I exported the file as XML and .DOC.

The first file can be read directly using

Import["SoLux Spectral Data.xls.xml", "XML"]

but you have to cut your way through the resulting XML expression tree.

The second method involves using MS Word. After opening the .doc file, I selected the table, copied it and pasted it in the following expression:

ImportString["","TSV"]

The insertion point should be precisely in the empty string (""). After pasting, you will get this dialog box:

Mathematica graphics

Press "Yes", evaluate the result and you get:

{{"Wavelength ", "4700K ", "4100K ", "3500K "}, {280, 0.049379, 0.054292, 0.0503}, {290, 0.075516, 0.037844, 0.034862}, {300, 0.11254, 0.030544, 0.028027}, {310, 0.16051, 0.033413, 0.029238}, {320, 0.23068, 0.067789, 0.055261}, {330, 0.32281, 0.20151, 0.13953}, {340, 0.40282, 0.43615, 0.25661}, {350, 0.45898, 0.57172, 0.52681}, {360, 1.2011, 0.82864, 1.3278}, {370, 1.8647, 1.5222, 1.6987}, {380, 2.5338, 2.3844, 3.61}, {390, 3.5809, 4.5686, 3.9927}, {400, 4.4137, 8.4548, 8.168}, {410, 5.2228, 14.205, 13.863}, {420, 6.0387, 17.949, 17.46}, {430, 6.9944, 21.068, 20.103}, ... }

If Word seems to copy only part of the table, try pasting it first in Excel before going to Mathematica, doing a bit of polishing there. Copying to the welcoming quotes in Mathematica will then do the trick.

$\endgroup$
1
  • 1
    $\begingroup$ @RHall Glad you like it, though I would be more pleased if a direct solution could be found. $\endgroup$ Commented Jul 16, 2013 at 21:29

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.