Skip to content

DBF Writer

DBF Writer provides writing DBF-like format to one or more table files in local file system.

Configuration Example

json
{
  "job": {
    "setting": {
      "speed": {
        "bytes": -1,
        "channel": 1
      }
    },
    "content": {
      "reader": {
        "name": "streamreader",
        "parameter": {
          "column": [
            {
              "value": "Addax",
              "type": "string"
            },
            {
              "value": 19880808,
              "type": "long"
            },
            {
              "value": "1989-06-04 00:00:00",
              "type": "date"
            },
            {
              "value": true,
              "type": "bool"
            },
            {
              "value": "中文测试",
              "type": "string"
            }
          ],
          "sliceRecordCount": 10
        }
      },
      "writer": {
        "name": "dbfwriter",
        "parameter": {
          "column": [
            {
              "name": "col1",
              "type": "char",
              "length": 100
            },
            {
              "name": "col2",
              "type": "numeric",
              "length": 18,
              "scale": 0
            },
            {
              "name": "col3",
              "type": "date"
            },
            {
              "name": "col4",
              "type": "logical"
            },
            {
              "name": "col5",
              "type": "char",
              "length": 100
            }
          ],
          "fileName": "test.dbf",
          "path": "/tmp/out",
          "writeMode": "truncate",
          "encoding": "GBK"
        }
      }
    }
  }
}

Parameters

ConfigurationRequiredData TypeDefault ValueDescription
pathYesstringNoneFile directory, note this is a folder, not a file
columnYeslist<map>NoneCollection of columns to be synchronized in configured table, see example configuration
fileNameYesstringNoneName of file to write
writeModeYesstringNoneData cleanup processing mode before writing, see description below
encodingNostringUTF-8File encoding, such as GBK, UTF-8
nullFormatNostring\NDefine which string can represent null
dateFormatNostringNoneFormat when date type data is serialized to file, e.g. "yyyy-MM-dd"

writeMode

Data cleanup processing mode before writing:

  • truncate: Clean all files with fileName prefix under directory before writing
  • append: No processing before writing, write directly using filename and ensure no filename conflicts
  • nonConflict: If there are files with fileName prefix under directory, report error directly

Type Conversion

Currently this plugin supports the following write types and corresponding relationships:

XBase TypeXBase SymbolJava Type used in JavaDBF
CharacterCjava.lang.String
NumericNjava.math.BigDecimal
Floating PointFjava.math.BigDecimal
LogicalLjava.lang.Boolean