Created
March 10, 2015 18:03
-
-
Save caschwartz/042ed9a13079e0d8f1a2 to your computer and use it in GitHub Desktop.
Query to create a CSV file to import into Excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: | |
: This main module queries basic Tanis postcards metadata for IA to create a | |
: CSV file to import into Excel. For Excel import, quotation marks are needed | |
: if value could contain a comma. Needed quotes for Title, Location, and Postcard-type. | |
:) | |
declare namespace ia = "http://digital.library.ptsem.edu/ia"; | |
declare namespace m = "http://www.loc.gov/mods/v3"; | |
declare namespace ptsl = "http://digital.library.ptsem.edu/"; | |
let $headers := "Identifier,Title,Location,Format-type,Postcard-type,Denomination" | |
let $metadata:= for $meta in fn:collection()/ia:doc/ia:metadata | |
let $id := $meta/ia:id | |
let $title := $meta/ia:title | |
let $city := $meta/ia:city | |
let $state := $meta/ia:state | |
let $format := $meta/ia:format | |
let $type := $meta/m:mods/m:extension/ptsl:type | |
let $denom := $meta/m:mods/m:extension/ptsl:denomination[@type="main"] | |
where $state = "OH" and $title != "" (: Limits by state and checks for metadata based on title :) | |
order by $id | |
return concat($id, ',', '"', $title, '"', ',', '"', $city, ', ', $state, '"', ',', $format, ',', '"', $type, '"', ',', $denom) | |
return ($headers, $metadata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment