bnvk / Conjuror

An experiment in the CSV format, open data, magic, and wizardly things!
Other
11 stars 2 forks source link

Can't open file while growing with coutput #46

Closed simonv3 closed 8 years ago

simonv3 commented 8 years ago

Here's the relevant data:

args: { targets: [],
  options: 
   { input: '/Users/simon/src/conjuror/data/ooni.csv',
     output: '',
     date: '',
     generated: 'today',
     invoicenumber: 0,
     extra: '',
     details: 'show',
     message: '',
     price: 'tally',
     currency: 'USD',
     formats: [] },
  config: 
   { default_template: 'wizard',
     path_templates: '/Users/simon/src/conjuror/templates/',
     path_output: '/Users/simon/src/conjuror/output/',
     user: 
      { ... },
     projects: [ [Object], [Object], [Object] ] },
  app_path: '/Users/simon/.node/lib/node_modules/conjuror/' }
Conjuror is starting up
passed to read.load: /Users/simon/src/conjuror/data/ooni.csv
Had a problem with opening file while Growing { message: 'datapackage.json is invalid JSON. Details: Unexpected token d' }

(I added console.log to print out those statements)

Basically, through inputs what comes available is the .csv data files is the things in my config.js (mimicking the config.js thing in this repo, which only lists .csv files under "path"). datapackage's read.load expects a datapackage.json file though (or at least a directory).

I'm not sure what I'm missing here.

bnvk commented 8 years ago

@simonv3 hrm, if I'm understanding the error, it is: message: 'datapackage.json is invalid JSON. Details: Unexpected token d' so, maybe check that in JSON link perhaps?

One thing, when we first made this, some reason I made the JSON template like [ { ... } ] which that array was unneeded. The code now would error on that. So check that it it is { ... }

simonv3 commented 8 years ago

It's passing in the CSV file, not the actual schema, which is what it picks up in the questions. So it's not a JSON file! I guess my question was more - should this be a json file? As far as I understand it's picking it from the path in my config.json projects object for each project.

bnvk commented 8 years ago

@simonv3 maybe paste your datapackage.json file here or encrypted email it to me?

simonv3 commented 8 years ago

Turns out I can't use ctrack either, I've updated my config:

{
  "default_template": "wizard",
  "path_templates": "/Users/simon/src/conjuror/templates/",
  "path_output": "/Users/simon/src/conjuror/output/",
  "user": {...},
  "projects": [{
    "name": "OONI",
    "path": "/Users/simon/src/conjuror/data/ooni.json"
  },...]
}

To point to a datapackage.json file, which got me further. Now it's stumbling across the Conjuror.readManuscript(json_data.resources[0].url) call:

/Users/simon/.node/lib/node_modules/conjuror/cli/conjuror-track.js:176
      Conjuror.readManuscript(json_data.resources[0].url)
                                                    ^
TypeError: Cannot read property 'url' of undefined
    at /Users/simon/.node/lib/node_modules/conjuror/cli/conjuror-track.js:176:53
    at /Users/simon/.node/lib/node_modules/conjuror/node_modules/datapackage-read/datapackage-read.js:38:7
    at fs.js:265:20
    at FSReqWrap.oncomplete (fs.js:99:15)

I suspect we need to properly define what the config.json looks like, and in the case of ctrack and coutput define what the data for each object should look like. I think what's in templates/ might not be up to date? (that's what I'm modelling my files on). A setup to add a project might go a long way for this? It could automatically add it to config.json and then create the data file in the wherever the user's data directory is (also specified in config.json)

bnvk commented 8 years ago

@simonv3 please pull recent master, that output calling conjuror-track.js is out of date! The command crack has been replaced with conjuror track I elaborated on this in this comment. Some of these changes were on the new branch, which I just merged. Sorry for the confusion!

simonv3 commented 8 years ago

I thought I had, let me try!

simonv3 commented 8 years ago

So, just updated with npm install -g conjuror and ran conjuror track and it stumbles on the same error:

/Users/simon/.node/lib/node_modules/conjuror/cli/track.js:169
      Conjuror.readManuscript(json_data.resources[0].url)
                                                    ^
TypeError: Cannot read property 'url' of undefined
    at /Users/simon/.node/lib/node_modules/conjuror/cli/track.js:169:53
    at /Users/simon/.node/lib/node_modules/conjuror/node_modules/datapackage-read/datapackage-read.js:38:7
    at fs.js:265:20
    at FSReqWrap.oncomplete (fs.js:99:15)

In the example work.json file I don't see a reference to a url in the resources object https://github.com/bnvk/Conjuror/blob/master/templates/work.json#L6.

bnvk commented 8 years ago

@simonv3 right you are, there is no .url in the schema file. That is actually something that gets created by datapackaage-read module, I believe, which adds url, name to the resource's schema object. Did you do npm install after the global install instance? I think that url value is auto generated and just maps to where your local file is

simonv3 commented 8 years ago

Woop. You're right, it does get automatically generated.

My work.json file was wrong - it was encompassed in an array (like you had mentioned I think?). Once I removed that array and fixed my data file things were better. Cool! Back at where I was :P.