0

I am starting a project to import a CSV, transform it, and re-export back to a new CSV. Step one has been to get Node CSV up and running.

I have installed the node-csv-npm package to my Meteor app directory and confirmed in terminal that I am "already using" node-csv-npm.

Yet, for some reason, when I run the basic example to test my set-up (see code), I get back "Uncaught ReferenceError: csv is not defined"

Simple Coffee Code I am using:

if Meteor.isClient
    console.log "client started."
    csv().from.string("#Welcome\n\"1\",\"2\",\"3\",\"4\"\n\"a\",\"b\",\"c\",\"d\"", comment: "#").to.array (data) ->
        console.log data
        # [ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ]

if Meteor.isServer
    console.log "Server Started"

Thanks for any insight!


As requested in comments, posting entire app code (.coffee file)

if Meteor.isClient
    console.log "Client Started"

if Meteor.isServer
    console.log "Server Started"
    csv().from.string("#Welcome\n\"1\",\"2\",\"3\",\"4\"\n\"a\",\"b\",\"c\",\"d\"", comment: "#").to.array (data) ->
        console.log data
        # [ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ]
ppedrazzi
  • 787
  • 2
  • 10
  • 23
  • Are you using the `npm` package as suggested [here](http://stackoverflow.com/questions/15583438/2013-meteor-npm-packages)? – David Weldon Nov 20 '13 at 18:57
  • Have you actually added the .js file on the client using the `api.add_files` call? Clients do not have access to node, so the script must be added directly. – sbking Nov 20 '13 at 19:20
  • @cuberto: I moved the code to the server, but still no go. In the console I see "ReferenceError: csv is not defined". – ppedrazzi Nov 20 '13 at 19:35
  • @DavidWeldon, I am using: https://atmosphere.meteor.com/package/node-csv-npm – ppedrazzi Nov 20 '13 at 19:38
  • @Cuberto: No require required as I am using: https://github.com/Dsyko/meteor-node-csv. I posted the full code above, but it's essentially my initial post as I am just trying to get csv to work right now. Also of note, I can see the "node-csv-npm" folder in my packages directory, so it's there. – ppedrazzi Nov 20 '13 at 19:45
  • 1
    Oh, try using `CSV()` instead of `csv()`. – sbking Nov 20 '13 at 19:47
  • @Cuberto - YES! That was it. Thank you very much for sticking with me on this one. Super helpful!! – ppedrazzi Nov 20 '13 at 21:56

0 Answers0