Re: Import syntax question
- To: mathgroup at smc.vnet.net
- Subject: [mg85506] Re: [mg85440] Import syntax question
- From: "Igor C. Antonio" <igora at wolf-ram.com>
- Date: Wed, 13 Feb 2008 04:09:07 -0500 (EST)
- Organization: Wolfram Research, Inc.
- References: <200802101022.FAA18017@smc.vnet.net>
- Reply-to: igora at wolf-ram.com
Hi Mark, You should do: Import["file.pdf", {{"Author", "Title"}}] or Import["file.pdf", {"PDF", {"Author", "Title"}]. The general syntaxes for extracting elements are: Import["file", {"format", "elem1"}] ---> import elem1 of "file" imported as "format." Import["file", {"format", "elem1", "subelem1", ...}] ---> When elem1 is itself a list of elements, you can import its "subelements." This one means import the subelem1 of elem1 (when elem1 is a list of rules) of the "file" imported as "format." Import["file", {"format", {"elem1", "elem2", "elem3"...}}] ---> This is the syntax for importing multiple elements. To make things a little more confusing ;), there's a shorthand notation when the second argument is *only one string*: You can omit the {}'s: Import["file.pdf", "Author"] Import["file.pdf", "Title"] Import uses FileFormat[] for format detection if you don't explicitly specify the "format," but the {}'s must remain as shown above if your second argument contains more than one string. Igor -- Igor C. Antonio Wolfram Research, Inc. http://www.wolfram.com To email me personally, remove the dash. Mark Fisher wrote: > Hi all, > > I find Import wonderful but frustrating. For example, I can get > individual items such as "Author" and "Title" in separate calls: > > Import["file.pdf", "Author"] > Import["file.pdf", "Title"] > > but I can't get a list as in > > Import["file.pdf", {"Author", "Title"}] > > Instead I get an error message that say "Title" is not present (which > seems misleading at best, since I already accessed it above). Is that > syntax supposed to work or not? (Frankly, I'm having a hard time > figuring out what the proper generic syntax is for Import, especially > since there are so few examples in the documentation.) > > BTW, I found out I can use > > {"Author", "Title"} /. Import["file.pdf", "Rules"] > > Is that what I "should" be doing? (It seems like overkill since Import > has to import a bunch more stuff that I don't want, at least in this > example.) > > --Mark
- References:
- Import syntax question
- From: Mark Fisher <particlefilter@gmail.com>
- Import syntax question