/usr/share/doc/python-dbfread-doc/html/_sources/exporting_data.rst.txt is in python-dbfread-doc 2.0.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | .. highlight:: python
Moving data to SQL, CSV, Pandas etc.
====================================
CSV
---
This uses the standard library ``csv`` module:
.. literalinclude:: ../examples/print_csv.py
The output is::
NAME,BIRTHDATE
Alice,1987-03-01
Bob,1980-11-12
Pandas Data Frames
------------------
.. literalinclude:: ../examples/pandas_dataframe.py
This will print::
BIRTHDATE NAME
0 1987-03-01 Alice
1 1980-11-12 Bob
The ``iter()`` is required. Without it Pandas will not realize that it
can iterate over the table.
Pandas will create a new list internally before converting the records
to data frames. This means they will all be loaded into memory. There
seems to be no way around this at the moment.
dataset (SQL)
-------------
The `dataset <https://dataset.readthedocs.io/>`_ package makes it easy
to move data to a modern database. Here's how you can insert the
``people`` table into an SQLite database:
.. literalinclude:: ../examples/using_dataset.py
(This also creates the schema.)
dbf2sqlite
----------
You can use the included example program ``dbf2sqlite`` to insert
tables into an SQLite database::
dbf2sqlite -o example.sqlite table1.dbf table2.dbf
This will create one table for each DBF file. You can also omit the
``-o example.sqlite`` option to have the SQL printed directly to
stdout.
If you get character encoding errors you can pass ``--encoding`` to
override the encoding, for example::
dbf2sqlite --encoding=latin1 ...
|