jagreygoose

Google Books Library XML Output to CSV

Jun 16th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Output Google Books Library XML Files to CSV
  2. # For creating labels for new library books
  3. # $UID is the primary key for the library system, make sure you select a free range
  4. # the script auto increments $UID from the selected starting point for each book
  5.  
  6. [xml]$books = Get-Content D:\AR_Middle_years.xml
  7.  
  8.  $UID = 9000
  9.  
  10.  $bookObj = $books.library.books.book | ForEach-Object {
  11.       New-Object PSCustomObject -Property @{
  12.         "ISBN" = $_.identifier.value
  13.         "Title" = $_.title
  14.         "Author" = $_.contributor
  15.         "ID" = $UID++
  16.       }
  17.  }
  18.  
  19.  $bookObj | Select Title, Author, ISBN, ID | Export-Csv -NoTypeInformation -Path D:\Books.csv
Add Comment
Please, Sign In to add comment