Skip to content

Commit

Permalink
keep convert in filename
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Sep 12, 2017
1 parent 78f4ca3 commit fb1e8f5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/converters/convertDbfToData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import readDbf from '../readers/readDbf'
import writeData from '../writers/writeData'

/**
* Reads in a dbf file with `.readDbf` and write to file using `.writeData`. A convenience function for converting DBFs to more useable formats. Formerly known as `writeDbfToData` and is aliased for legacy support.
*
* @param {String} inFileName the input file name
* @param {String} outFileName the output file name
* @param {Object} [options] Optional config object, see below
* @param {Boolean} [options.makeDirectories=false] If true, create intermediate directories to your data file.
* @param {Function} callback callback that takes error (if any)
*
* @example
* io.convertDbfToData('path/to/data.dbf', 'path/to/data.csv', function (err) {
* console.log(err)
* })
*
* io.convertDbfToData('path/to/data.dbf', 'path/to/create/to/data.csv', {makeDirectories: true}, function (err) {
* console.log(err)
* })
*/
export default function convertDbfToData (inPath, outPath, opts_, cb) {
if (typeof cb === 'undefined') {
cb = opts_
}
readDbf(inPath, function (error, jsonData) {
if (error) {
cb(error)
} else {
writeData(outPath, jsonData, opts_, cb)
}
})
}

0 comments on commit fb1e8f5

Please sign in to comment.