Documentation ¶
Overview ¶
Package dbf reads and writes DBF files.
Index ¶
- type Fields
- func (f *Fields) AddCharacterField(name string, length int)
- func (f *Fields) AddDateField(name string)
- func (f *Fields) AddLogicalField(name string)
- func (f *Fields) AddNumericField(name string, length, dec int)
- func (f *Fields) Count() int
- func (f *Fields) Err() error
- func (f *Fields) FieldInfo(index int) (name, typ string, length, dec int)
- type Reader
- func (r *Reader) BoolFieldValue(index int) bool
- func (r *Reader) CodePage() int
- func (r *Reader) DateFieldValue(index int) time.Time
- func (r *Reader) Deleted() bool
- func (r *Reader) Err() error
- func (r *Reader) Fields() *Fields
- func (r *Reader) FloatFieldValue(index int) float64
- func (r *Reader) IntFieldValue(index int) int64
- func (r *Reader) ModDate() time.Time
- func (r *Reader) Read() bool
- func (r *Reader) RecordCount() uint32
- func (r *Reader) SetCodePage(cp int)
- func (r *Reader) StringFieldValue(index int) string
- type Writer
- func (w *Writer) Err() error
- func (w *Writer) Flush()
- func (w *Writer) SetBoolFieldValue(index int, value bool)
- func (w *Writer) SetDateFieldValue(index int, value time.Time)
- func (w *Writer) SetDeteted(deleted bool)
- func (w *Writer) SetFloatFieldValue(index int, value float64)
- func (w *Writer) SetIntFieldValue(index int, value int64)
- func (w *Writer) SetStringFieldValue(index int, value string)
- func (w *Writer) Write()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fields ¶ added in v0.2.0
type Fields struct {
// contains filtered or unexported fields
}
Fields for creating file structure.
func NewFields ¶ added in v0.2.0
func NewFields() *Fields
NewFields returns a pointer to a structure Fields.
func (*Fields) AddCharacterField ¶ added in v0.3.0
AddCharacterField adds a character field to the structure.
func (*Fields) AddDateField ¶ added in v0.3.0
AddDateField adds a date field to the structure.
func (*Fields) AddLogicalField ¶ added in v0.3.0
AddLogicalField adds a logical field to the structure.
func (*Fields) AddNumericField ¶ added in v0.3.0
AddNumericField adds a numeric field to the structure.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
The Reader reads records from a DBF file.
func (*Reader) BoolFieldValue ¶ added in v0.4.0
BoolFieldValue returns the value of the field by index. Field type must be Logical.
func (*Reader) DateFieldValue ¶ added in v0.4.0
DateFieldValue returns the value of the field by index. Field type must be Date.
func (*Reader) Err ¶ added in v0.4.0
Err returns the first error that was encountered by the Reader.
func (*Reader) FloatFieldValue ¶ added in v0.4.0
FloatFieldValue returns the value of the field by index. Field type must be Numeric.
func (*Reader) IntFieldValue ¶ added in v0.4.0
IntFieldValue returns the value of the field by index. Field type must be Numeric. If field decimal places is not zero, then it returns the integer part of the number.
func (*Reader) Read ¶
Read reads one record from r. Returns false if end of file is reached or an error occurs.
func (*Reader) RecordCount ¶
RecordCount returns the number of records in the DBF file.
func (*Reader) SetCodePage ¶
SetCodePage sets the code page if no code page is set in the file header.
Supported code pages:
437 - US MS-DOS 850 - International MS-DOS 1252 - Windows ANSI 10000 - Standard Macintosh 852 - Easern European MS-DOS 866 - Russian MS-DOS 865 - Nordic MS-DOS 1255 - Hebrew Windows 1256 - Arabic Windows 10007 - Russian Macintosh 1250 - Eastern European Windows 1251 - Russian Windows 1254 - Turkish Windows 1253 - Greek Windows
func (*Reader) StringFieldValue ¶ added in v0.4.0
StringFieldValue returns the value of the field by index. Field type must be Character.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer writes records in DBF file. The writes of individual records are buffered. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.
func NewWriter ¶
NewWriter returns a new Writer that writes to w. The function writes the header of the DBF file. If you call the Flash method afterwards, an empty file will be created.
Supported code pages:
437 - US MS-DOS 850 - International MS-DOS 1252 - Windows ANSI 10000 - Standard Macintosh 852 - Easern European MS-DOS 866 - Russian MS-DOS 865 - Nordic MS-DOS 1255 - Hebrew Windows 1256 - Arabic Windows 10007 - Russian Macintosh 1250 - Eastern European Windows 1251 - Russian Windows 1254 - Turkish Windows 1253 - Greek Windows
If the codePage parameter is zero, the text fields will not be encoded.
func (*Writer) Err ¶ added in v0.4.0
Err returns the first error that was encountered by the Writer.
func (*Writer) Flush ¶
func (w *Writer) Flush()
Flush writes any buffered data to the underlying io.Writer.
func (*Writer) SetBoolFieldValue ¶ added in v0.4.0
SetBoolFieldValue assigns a value to a field by index. Field type must be Logical.
func (*Writer) SetDateFieldValue ¶ added in v0.4.0
SetDateFieldValue assigns a value to a field by index. Field type must be Date.
func (*Writer) SetDeteted ¶ added in v0.4.1
SetDeleted sets record mark is deleted.
func (*Writer) SetFloatFieldValue ¶ added in v0.4.0
SetFloatFieldValue assigns a value to a field by index. Field type must be Numeric.
func (*Writer) SetIntFieldValue ¶ added in v0.4.0
SetIntFieldValue assigns a value to a field by index. Field type must be Numeric.
func (*Writer) SetStringFieldValue ¶ added in v0.4.0
SetStringFieldValue assigns a value to a field by index. Field type must be Character.