This question is answered.


Permlink Replies: 20 - Pages: 2 [ Previous | 1 2 ] - Last Post: 12-Nov-2015 00:11 Last Post By: RobM
boonenf

Posts: 33
Registered: 04/20/10
Re: export list of Title and Location
Posted: 12-Oct-2015 19:10   in response to: jimberry in response to: jimberry
 
  Click to reply to this thread Reply
I already tried this one but it results in 'Image' for every image.
So this is not exactly what I have in mind.
Every image belongs to a category(sub directory) like 'Deforestation', 'Fires', 'Dust', etc....
as you can see at our Image Gallery

http://proba-v.vgt.vito.be/content/proba-v-gallery

The purpose is to add an Excel-field with the Category('Deforestation', 'Fires', 'Dust'), of each image

Edited by: boonenf on 12-Oct-2015 19:10

Edited by: boonenf on 12-Oct-2015 19:11
jimberry

Posts: 7,459
Registered: 08/30/04
Re: export list of Title and Location
Posted: 12-Oct-2015 19:32   in response to: boonenf in response to: boonenf
 
  Click to reply to this thread Reply
boonenf wrote:
I already tried this one but it results in 'Image' for every image.
So this is not exactly what I have in mind.
Every image belongs to a category(sub directory) like 'Deforestation', 'Fires', 'Dust', etc....
as you can see at our Image Gallery
So if the category is not defined in the metadata, where is it defined? From where does the Drupal album obtain the category?
RobM

Posts: 4,250
Registered: 08/04/06
Re: export list of Title and Location
Posted: 12-Oct-2015 20:50   in response to: boonenf in response to: boonenf
 
  Click to reply to this thread Reply
Attachment tool_export.bsh (1.6 KB)
Try the attached updated tool.
I have appended the category, based on the title of the current subfolder.
Is that what you want?

Edited by: RobM on 11-Nov-2015 23:10
Updated file to include corrections and added dialogue before running.
boonenf

Posts: 33
Registered: 04/20/10
Re: export list of Title and Location
Posted: 14-Oct-2015 09:24   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
It gives this error
boonenf

Posts: 33
Registered: 04/20/10
Re: export list of Title and Location
Posted: 14-Oct-2015 10:02   in response to: boonenf in response to: boonenf
 
  Click to reply to this thread Reply
Found it! I guess you where a little hasty when you changed the code :-)
This part of the code

category = root.vars.get("title");

had to be placed in another part, but, hey, thanks to you it is complete now.
Thank you again for your help and quick responses.

_____________________________________________
import se.datadosen.util.*;
import se.datadosen.jalbum.*;

File f = new File(rootOutputDirectory + "GPS.csv");
if (!f.exists()) IO.writeTextFile("\"Title\",\"Location\",\"title\"", new File(rootOutputDirectory.getAbsolutePath(), "GPS.csv"));
FileOutputStream out; // declare file output object
out = new FileOutputStream(rootOutputDirectory + "/GPS.csv");
// Connect print stream to the output stream ready to generate the javascript code
p = new PrintStream( out );

p.println("\"Title\",\"Location\",\"Category\",\"title\"");
exportCSV(AlbumObject root) {
String name;
String location;
String category;
for (AlbumObject ao : root.getChildren()) {
Category cat = ao.getCategory();
if(cat == Category.image && ao.isIncluded()) {
Scope vars = ao.getVars();
name = vars.get("title");
name = name.replaceAll("\"", """);
location = vars.get("location");
if(location == null) location = "";
category = root.vars.get("title");
p.println("\"" + name + "\",\"" + location + "\",\"" + category + "\"");
}
// process subfolders
if (cat == Category.folder && !ao.isHidden() && ao.isIncluded()) {
exportCSV(ao);
}
}
}
exportCSV(rootFolder);

RobM

Posts: 4,250
Registered: 08/04/06
Re: export list of Title and Location
Posted: 14-Oct-2015 11:20   in response to: boonenf in response to: boonenf
Helpful
  Click to reply to this thread Reply
Sorry for the error, I just modified the code on my iPad and didn't actually try it. Nice that you figured out the correction.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums