AppleScript find and replace

AppleScript question

MacBook Pro 13in mid2012 2.9GHz i7 16GB macOS High Sierra 10.13.6

This is not a homework/school project


First off I am a rank novice at coding ANYTHING and I don't know where to start


I am trying to convert some PDF/Pages documents (recipes) into a .csv file (to upload to a "database" Online database "airtable.com" to do meal planning for the week and to create a shopping list for the week.

As best I can figure out in order to get the information separated properly so that it can be compiled into the weekly shopping list, I have to have the amount, unit, ingredient and any notes separated by a comma. (ex: 1 pound beef diced (how it is in the document) needs to become 1, pound, beef, diced). With what I have dug through from professor google there is a way to start coding a comma to be inserted with applescript. But what I am finding is it is getting pretty complex because some times there wont be a unit in the recipe ie 1 lime or there will be time when fractions will be used it 1 1/2 cup.


I may be totally over think this but I can not find any good easy answer to automate this process anywhere. Any help or advice you all could offer would be amazing thanks.


JJ

MacBook Pro, macOS High Sierra (10.13.6), mid 2012

Posted on Sep 5, 2018 8:16 PM

Reply
9 replies

Sep 6, 2018 7:29 PM in response to drjj

The challenge will be parsing the text to get the correct content out of it. This can potentially be very time consuming, and frustrating, to develop the right code logic to parse your data from different formats of recipes, and extracted text. There is no assurance that extracting text from a PDF will always produce the same repetitious content, or layout format.


You will need more than a Python or Ruby course, and I believe AppleScript would be unsuitable for the entire project.

Sep 6, 2018 7:15 AM in response to drjj

Pages v7.1, or Pages '09 v4.3?


Screen captures of a typical PDF, and Pages recipe (including examples with fractions)? Use the camera icon on this toolbar to post them here.


Single, or multiple recipe per document? White-space, or other surrounding text to sift through to access the recipe?


This all matters when determining the degree of difficulty in automating a solution.

Sep 6, 2018 10:03 AM in response to VikingOSX

How to show us a screen image. Avoid personal identification.

on the Mac you do:

command + shift + 3 Will take entire screen. You hear a click.

command + shift + 4 Lets you decide what to take. Mouse pointer changes. Move mouse to upper left corner of desire image. Hold down left mouse key where to start image. Drag mouse to lower left of where you want to stop image. Release mouse.


You will get a file starting with Screen Shot ... .png on the desktop. example:

Screen Shot 2016-09-20 at 2.27.47 PM



User uploaded file


click on camera icon.


another window will appear.


click on Browse button


An open file panel appears. Select the file.


User uploaded file


After selection a file, I have this screen showing.


User uploaded file

Click on file you wish to select. Click on the Open button.


You come back to Select an Image. Cclick on Insert Image button. You may have to scroll down to see Insert Image button.

alternative explanation: https://discussions.apple.com/docs/DOC-6917

Sep 6, 2018 1:55 PM in response to VikingOSX

Running pages v7.1 numbers 5.1


Dropbox - Test for recipe extractions

Here is a link to a copy of the files and such that I created trying even figure out what I needed. Including some of the pages documents and numbers documents


Most of the recipes will be downloaded in PDF form from different websites/books etc. thus far I have run them through OCR's (Automator) to get a .txt file and opened it with pages. (but I am willing to change workflow to whatever makes this part the easiest as it seems to be my rate-limiting step). That being said I will have multipage pages files ready to go as soon as this part gets figured out here are some sample images with what I have been working with to help:

1 page of multipage pdf

User uploaded file

OCR text extraction of that document

User uploaded file

As for output what I am trying to get to is two sheets in number (two separate files if need be)

The ingredients sheet:

User uploaded file

The instruction list:

User uploaded file

This is honestly all negotiable I am just trying to find a way to properly compile all the recipes I have accumulated over the years and make a meal plan out of them with shopping lists to make life easier


Thanks let me know if you need anything else

Sep 7, 2018 6:52 AM in response to VikingOSX

Awesome thanks again! As far as the format I am still playing with the initial setup I think it will be close to the pages document but for ease, I may split out the ingredients and the instructions. I was also thinking that a find and replace of the " 1/4" (fraction) to a ".25" might save some headaches. Again thanks so much for your time! And Help Ill look into python

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript find and replace

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