DBFRead
Signatures
DBFRead(VARCHAR path, VARCHAR tableName);
DBFRead(VARCHAR path, VARCHAR tableName, VARCHAR fileEncoding);
Description
Reads the file specified by path
as a dBase file and
copies its contents into a new table tableName
in the database.
Define fileEncoding
to force encoding (useful when the header is
missing encoding information).
Examples
-- Basic syntax:
CALL DBFRead('/home/user/file.dbf', 'tableName');
-- In the next two examples, we show what happens when we attempt to
-- read a DBF file with the wrong encoding, and how to fix it. Here
-- UTF-8 doesn't understand accented characters, so "Sévérac" is
-- displayed as "S".
CALL DBFRead('/home/user/COMMUNE.DBF', 'commune44utf', 'utf-8');
SELECT * FROM commune44utf LIMIT 2;
-- Answer:
-- | NOM | CODE_INSEE | DEPART | REGION |
-- |--------|------------|------------------|------------------|
-- | Puceul | 44138 | LOIRE-ATLANTIQUE | PAYS DE LA LOIRE |
-- | S | 44196 | LOIRE-ATLANTIQUE | PAYS DE LA LOIRE |
-- To fix this problem, we specify the right encoding:
CALL DBFRead('/home/user/COMMUNE.DBF', 'commune44iso',
'iso-8859-1');
SELECT * FROM commune44iso LIMIT 2;
-- Answer:
-- | NOM | CODE_INSEE | DEPART | REGION |
-- |---------|------------|------------------|------------------|
-- | Puceul | 44138 | LOIRE-ATLANTIQUE | PAYS DE LA LOIRE |
-- | Sévérac | 44196 | LOIRE-ATLANTIQUE | PAYS DE LA LOIRE |
See also