New York vs. New Jersey Broccoli Production
Created: 2011-09-21 08:39:27
Last updated: 2011-09-21 08:41:26
Uses the SpreadsheetImport service to import data from an Excel spreadsheet. The workflow imports two files and generates a single graph comparing the information from the two spreadsheets.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Spreadsheet Import Example |
Descriptions (1)
Example using the SpreadsheetImport service to import data from an Excel spreadsheet.
The workflow imports the file spreadsheet file WaterUse.xlsx and generates a graph from the date.
The source data is from http://data.gov.uk/ |
Dependencies (0)
Processors (7)
Name |
Type |
Description |
SpreadsheetImport |
spreadsheet |
|
GenerateGraphURL |
beanshell |
ScriptStringBuilder sb = new StringBuilder();
sb.append("http://chart.apis.google.com/chart?");
sb.append("cht=bvg");
sb.append("&chs=400x400");
sb.append("&ch=");
sb.append("&chxt=x,y,y");
sb.append("&chbh=5,5,5");
sb.append("&chxr=0,");
sb.append(Float.parseFloat(years.get(0)).intValue());
sb.append(",");
sb.append(Float.parseFloat(years.get(years.size() - 1)).intValue());
sb.append(",2|1,0,3500");
sb.append("&chds=0,3500");
sb.append("&chxl=2:|Acres");
sb.append("&chxp=2,50");
sb.append("&chco=00cc99,006699,cccccc,cc99cc");
sb.append("&chdl=");
for (int i = 0; i < headers.size(); i++) {
sb.append(headers.get(i).replace(" ", "%20"));
if (i+1 < data.size()) {
sb.append("|");
}
}
if (title != void) {
sb.append("&chtt=");
sb.append(type);
}
if (data != void) {
sb.append("&chd=t:");
for (int i = 0; i < data.size(); i++) {
List data1 = (List) data.get(i);
for (int j = 0; j < data1.size(); j++) {
Float value = Float.parseFloat(data1.get(j));
sb.append(value.intValue());
if (j+1 < data1.size()) {
sb.append(",");
}
}
if (i+1 < data.size()) {
sb.append("|");
}
}
}
graphURL = sb.toString(); |
Get_Image_From_URL |
localworker |
ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
} else {
inputURL = new URL(url);
}
byte[] contents;
if (inputURL.openConnection().getContentLength() == -1) {
// Content size unknown, must read first...
byte[] buffer = new byte[1024];
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
totalBytesRead += bytesRead;
bytesRead = is.read(buffer, 0, 1024);
}
contents = new byte[totalBytesRead];
} else {
contents = new byte[inputURL.openConnection().getContentLength()];
}
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
bytesRead = is.read(contents, totalBytesRead, contents.length - totalBytesRead);
totalBytesRead += bytesRead;
if (contents.length==totalBytesRead) break;
}
image = contents;
|
url_value_NY |
stringconstant |
Valuehttp://www.myexperiment.org/files/570/download/PS3-NY-Broccoli.xls |
url_value_NJ |
stringconstant |
Valuehttp://www.myexperiment.org/files/569/download/PS3-NJ-Broccoli.xls |
SpreadsheetImport_2 |
spreadsheet |
|
Beanshell |
beanshell |
Scriptdata = new ArrayList();
headers = new ArrayList();
headers.add(NY_areaPlanted.remove(0));
headers.add(NY_areaHarvested.remove(0));
headers.add(NJ_areaPlanted.remove(0));
headers.add(NJ_areaHarvested.remove(0));
data.add(NY_areaPlanted);
data.add(NY_areaHarvested);
data.add(NJ_areaPlanted);
data.add(NJ_areaHarvested);
year.remove(0);
years = year; |
Beanshells (2)
Name |
Description |
Inputs |
Outputs |
GenerateGraphURL |
|
title
data
headers
years
|
graphURL
|
Beanshell |
|
year
NY_areaPlanted
NY_areaHarvested
NJ_areaPlanted
NJ_areaHarvested
|
data
headers
years
|
Outputs (1)
Name |
Description |
graph |
Final graph derived from values pulled from spreadsheet
|
Datalinks (12)
Source |
Sink |
url_value_NY:value |
SpreadsheetImport:fileurl |
Beanshell:years |
GenerateGraphURL:years |
Beanshell:headers |
GenerateGraphURL:headers |
Beanshell:data |
GenerateGraphURL:data |
GenerateGraphURL:graphURL |
Get_Image_From_URL:url |
url_value_NJ:value |
SpreadsheetImport_2:fileurl |
SpreadsheetImport:NY_areaHarvested |
Beanshell:NY_areaHarvested |
SpreadsheetImport:NY_areaPlanted |
Beanshell:NY_areaPlanted |
SpreadsheetImport_2:NJ_areaHarvested |
Beanshell:NJ_areaHarvested |
SpreadsheetImport_2:NJ_areaPlanted |
Beanshell:NJ_areaPlanted |
SpreadsheetImport:year |
Beanshell:year |
Get_Image_From_URL:image |
graph |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (2)
(People/Groups)
Attributions (3)
(Workflows/Files)
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment