GithubHelp home page GithubHelp logo

openknowledge-archive / datapackage-to-google-spreadsheet Goto Github PK

View Code? Open in Web Editor NEW
8.0 7.0 2.0 138 KB

[EXPERIMENTAL] Import data packages (http://data.okfn.org/doc/data-package) into Google Spreadsheets

datapackage-to-google-spreadsheet's Introduction

datapackage-to-google-spreadsheet

Import tabular data packages (http://data.okfn.org/doc/data-package) into Google Spreadsheets

Demo

To import a tabular data pacakage into Google Spreadsheets:

  1. Go to https://docs.google.com/spreadsheet/ccc?key=0AqR8dXc6Ji4JdG15Z1BhNXpCMFBnVTY5LUpoTGNrY0E#gid=0
  2. Make a copy of the sheet
  3. Go to Data Packages Menu -> Import Data (on the first run, you will be asked for authorization)
  4. Paste in the url: http://data.okfn.org/data/house-prices-us/datapackage.json
  5. Watch the data load!

Note: You can replace the datapackage.json url with any other tabular data package link

How it works

A small script is included in the spreadsheet. This in turn uses a library (the code from this repository) that loads and processes CSV data from the data package.

Do it yourself

To use the script in your own spreadsheets:

  1. In your spreadsheet open the script editor to create a new script

  2. Include the library. To do this:

    1. Go to Resources => Manage Resources
    2. Use the project id: MH6zwb-fUDq8QyPrl-PbJlu_4T1jeIs
    3. Make sure that the latest version is selected
    4. More information on using libraries can be found here: https://developers.google.com/apps-script/guide_libraries#useLibrary
  3. Copy and paste the following into your script and hit save:

function onOpen() {
DataPackages.onOpen();
}
function importDataPackageUi() {
DataPackages.importDataPackageUi();
}
  1. Hit run
  2. There is now a new Data Packages menu in your spreadsheet. Whenever you open the spreadsheet in the future it will be there.

Data Requirements

Currently, the library can cope with a single CSV file from a tabular data package. The field separator should be a comma, the text delimiter should be " and the line separator should be \n. That means we're not yet fully conformant with the specification, but this will hopefully be achieved soon via a more general API that pre-processes the data according to format and dialect.

Deploying

The contents of the file library.gs.js should replace the code here:

https://script.google.com/macros/d/1GLuZPrroyUP4WkHm4aAT4Z2QUqoL60LhEJnomYZT7nzaMDjptOneTNdJ/edit

The contents of the file linking_code.gs.js need to be placed in the spreadsheet script, and the README.md (this file) updated accordingly.

datapackage-to-google-spreadsheet's People

Contributors

mattfullerton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

datapackage-to-google-spreadsheet's Issues

Good test data package

  • Multiple resources
  • Quoted quotes/text
  • Entries with new lines
  • All supported data types

Data package export from Google Spreadsheet?

Is there a complementary app to this that allows the export of a data package from a Google Spreadsheet?

eg we can use Google Query language (example feed) to get a quick summary of the data types associated with a column.

google.visualization.Query.setResponse(
  {"version":"0.6", "reqId":"0", "status":"ok", "sig":"1319450576",
   "table":{
      "cols":[
        {"id":"A", "label":"Text col", "type":"string"},
        {"id":"B","label":"Currency col","type":"number","pattern":"[$£-809]#,##0.00"},
        {"id":"C","label":"Date col","type":"date","pattern":"dd/MM/yyyy"}],
      "rows":[{"c":[
        {"v":"hello"},
        {"v":10.0,"f":"£10.00"},
        {"v":new Date(2014,0,12),"f":"12/01/2014"}]}]
     }
  }
);

I'm not sure if there are Google Apps scripts calls that can return the same data?

We can also make use of metadata associated with a particular document PropertiesService.getDocumentProperties() to hold the data associated with certain of the datapackage elements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.