Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Find every number in a PDF?

Hey Apple Support,

I was given the task of finding every number in a 70 page PDF document. Instead of just going through manually, would there be a way of searching for ANYTHING including a number? I don't want it to find a specific number, I want it to find every single number in the document. Is there any way this is possible? You can link any sort of software that may help with this. I also do have Acrobat Pro, so that is an option for use. Let me know what you got!

MacBook Pro, OS X Mountain Lion (10.8.3)

Posted on Mar 19, 2014 12:55 PM

Reply
22 replies

Mar 20, 2014 12:33 PM in response to KooKilla

KooKilla wrote:


I didn't use the line number options so thats fine. An example of what i may have for data is something like "Brain Development: Research shows that the portion of the brain that assesses risk and danger does not fully develop until the mid 20’s". I would want this to be put under a "20" category with all other points that mention something about 20.


If you have this in plain text, then you're 90% of the way there. Let's assume you have something like


"I am 20. My friend is 30. Her husband is 40."


With this kind of data you can search by number and end up with:


10:

20: I am 20.

30: My friend is 30.

40: Her husband is 40.

50:



Is this what we're talking about? The more specific you can be the more tailored an answer we can provide.

Mar 20, 2014 12:36 PM in response to Phil Stokes

yeah something like this will work. I just need to get the numbers in the same group so I can put it into a table. If I can do something like you said, then thats easy as copy and pasting. Or it can also be like...


"I am 20. My friend is 30. Her husband is 40."


10:

20: "I am 20. My friend is 30. Her husband is 40."

30: "I am 20. My friend is 30. Her husband is 40."

40: "I am 20. My friend is 30. Her husband is 40."

50:


Where it will include the whole line and any other numbers. I just need to get the numbers and thier text with them in the same area so I can create a table.

Mar 20, 2014 5:11 PM in response to KooKilla

This bash script will work on the Report.txt file created with Automator:


#!/bin/bash

while read line
do
    name=$line
    s=$( echo "$name" | grep -Eo  '[0-9]{1,}' )
    a=($s)
    for i in "${a[@]}"
     do
         printf "%s %s\n" "$i": "$line" >> ~/Desktop/Report2.txt
     done
done < ~/Desktop/Report.txt
sort ~/Desktop/Report2.txt > ~/Desktop/ReportSorted.txt


This can easily be incorporated into the original Automator Workflow.

Just replace the Run Shell Script Action with:


textutil -stdout -convert txt "$1" | grep -E  '[0-9]{1,}' > ~/Desktop/Report.txt
while read line
do
    name=$line
    s=$( echo "$name" | grep -Eo  '[0-9]{1,}' )
    a=($s)
    for i in "${a[@]}"
  do
  printf "%s %s\n" "$i": "$line" >> ~/Desktop/Report2.txt
  done
done < ~/Desktop/Report.txt
sort ~/Desktop/Report2.txt > ~/Desktop/ReportSorted.txt
rm "$1" ~/Desktop/Report.txt ~/Desktop/Report2.txt


The Workflow is:


User uploaded file

User uploaded file


So, if the PDF is:


"I am 20. My friend is 30. Her husband is 40."

"I am 30. My friend is 40. Her husband is 50."


ReportSorted.txt will be:


20: "I am 20. My friend is 30. Her husband is 40."

30: "I am 20. My friend is 30. Her husband is 40."

30: "I am 30. My friend is 40. Her husband is 50."

40: "I am 20. My friend is 30. Her husband is 40."

40: "I am 30. My friend is 40. Her husband is 50."

50: "I am 30. My friend is 40. Her husband is 50."

Mar 20, 2014 5:10 PM in response to KooKilla

KooKilla wrote:


yeah something like this will work. I just need to get the numbers in the same group so I can put it into a table. If I can do something like you said, then thats easy as copy and pasting. Or it can also be like...


"I am 20. My friend is 30. Her husband is 40."


10:

20: "I am 20. My friend is 30. Her husband is 40."

30: "I am 20. My friend is 30. Her husband is 40."

40: "I am 20. My friend is 30. Her husband is 40."

50:


Where it will include the whole line and any other numbers. I just need to get the numbers and thier text with them in the same area so I can create a table.


Got it. You just need to make a change to the Run Shell Script Action in the Automator Workflow.

See the last post below.

Find every number in a PDF?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.