Skip to content

Commit cae4b72

Browse files
committed
Document how to load data as JSON string
1 parent 7572488 commit cae4b72

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bigquery/google/cloud/bigquery/client.py

+16
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,22 @@ def load_table_from_json(
16441644
json_rows (Iterable[Dict[str, Any]]):
16451645
Row data to be inserted. Keys must match the table schema fields
16461646
and values must be JSON-compatible representations.
1647+
1648+
.. note::
1649+
1650+
If your data is already a newline-delimited JSON string,
1651+
it is best to wrap it into a file-like object and pass it
1652+
to :meth:`~google.cloud.bigquery.client.Client.load_table_from_file`::
1653+
1654+
import io
1655+
from google.cloud import bigquery
1656+
1657+
data = u'{"foo": "bar"}'
1658+
data_as_file = io.StringIO(data)
1659+
1660+
client = bigquery.Client()
1661+
client.load_table_from_file(data_as_file, ...)
1662+
16471663
destination (Union[ \
16481664
:class:`~google.cloud.bigquery.table.Table`, \
16491665
:class:`~google.cloud.bigquery.table.TableReference`, \

0 commit comments

Comments
 (0)