 csvParse = require 'csv-parse'
 fs = require 'fs'
 _ = require 'lodash'
+Q = require 'q'
 
-exports.f = f = (input, callback) ->
-  csvParse input, (err, data) ->
-    callback err if err
+exports.f = f = (input) ->
+  Q.nfcall csvParse, input
+  .then (data) ->
     filtered = _.filter data, (i) ->
       1 < i.length
     ret = {}

      help: 'output file'
      required: true
    args = parser.parseArgs()
    io args.input, args.output

        min: parseFloat line[3]
        volume: parseFloat line[5]
        amount: parseFloat line[6]
    ret

exports.sync = sync = (inputFile, outputFile) ->
  Q.nfcall fs.readFile, inputFile, encoding: 'ascii'
  .then f
  .then (data) ->
    Q.nfcall fs.writeFile, outputFile, JSON.stringify(data), encoding: 'ascii'

if require.main == module
  do ->
