And while we’re told that export is a method, we’re not told what it’s a method of. You have to have seen example code using similar methods to know that the first argument is the document and the second is an object with key/value pairs for all the indented parameters. Now here’s the same documentation for the JavaScript version:ĭoes this look like JavaScript to you? It doesn’t to me. It’s written more or less as you would write it in AppleScript. And by “more” effort I mean “any.” Here’s the AppleScript dictionary entry for the Numbers export command. I might find it easier to get over my argument hangup if Apple put more effort into its JXA documentation. One of them is passed in as a regular variable, but the other two have to be rolled into an object. There are three arguments to this function. I just find it hard to get the hang of this syntax. It’s just a single step with a short bit of JavaScript code.ģ: // Get the top Numbers document and the path to its fileĥ: let topPathString = topDoc.file().toString()ħ: // Make the path to the CSV file we're going to export toĨ: let csvPath = Path(topPathString.replace(/\.numbers$/, ".csv")) ġ0: // Save the Numbers file and export it as CSVġ2: numbersApp.export(topDoc, ) So I made a macro that saves the Numbers file and exports a CSV file at the same time. In this process, it’s important that I keep the Numbers version of the table and the CSV version in sync. I move the data over to Numbers (I hate working in Excel), clean it up into a simple tabular form, and export it as CSV for analysis with Pandas and other bits of Python. I get lots of data from clients in Excel files that are formatted more for presentation than for analysis. I’m years into my attempt to use JavaScript for Automation (JXA) more than AppleScript, but Apple and its crummy JXA documentation keeps getting in my way.Īs an example of a case where I did use JXA, let’s look at a Keyboard Maestro macro I use quite often at work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |