You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/08/27 21:45:40 UTC

[GitHub] [arrow-cookbook] westonpace commented on a change in pull request #49: Recipe to read line delimited json as of ARROW-13708

westonpace commented on a change in pull request #49:
URL: https://github.com/apache/arrow-cookbook/pull/49#discussion_r697734957



##########
File path: python/source/io.rst
##########
@@ -497,3 +497,39 @@ the parquet file as :class:`ChunkedArray`
     pyarrow.Table
     col1: int64
     ChunkedArray = 0 .. 99
+
+Reading Line Delimited JSON
+===========================
+
+Arrow has builtin support for line-delimited JSON.
+Each line represents a row of data as a JSON object.
+
+Given some data in a file where each line is a JSON object
+containing a row of data:
+
+.. testcode::
+
+    import tempfile
+
+    with tempfile.NamedTemporaryFile(delete=False, mode="w+") as f:
+        f.write('{"a": 1, "b": 2.0, "c": 1}\n')
+        f.write('{"a": 3, "b": 3.0, "c": 2}\n')
+        f.write('{"a": 5, "b": 4.0, "c": 3}\n')
+        f.write('{"a": 7, "b": 5.0, "c": 4}\n')
+
+The content of the file can be read back to a :class:`pyarrow.Table` using
+:func:`pyarrow.json.read_json`
+
+.. testcode::
+
+    import pyarrow.json as pj
+
+    table = pj.read_json(f.name)
+
+.. testcode::
+
+    print(table.to_pydict())
+

Review comment:
       Is there any reason these code blocks can't be merged into a single code block?

##########
File path: python/source/io.rst
##########
@@ -497,3 +497,39 @@ the parquet file as :class:`ChunkedArray`
     pyarrow.Table
     col1: int64
     ChunkedArray = 0 .. 99
+
+Reading Line Delimited JSON
+===========================
+
+Arrow has builtin support for line-delimited JSON.
+Each line represents a row of data as a JSON object.
+
+Given some data in a file where each line is a JSON object
+containing a row of data:

Review comment:
       There seems to be some inconsistency how you lead up to a code example.
   
   ```
   I lead to this next example with a trailing colon:
   
   .. testcode::
   ```
   vs (the below is done in the writing CSV examples)
   ```
   I lead to this next example without any punctuation
   
   .. testcode::
   ```
   
   I don't think there is any right or wrong way but it might be nice to aim for consistency.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org