@@ -21,7 +21,7 @@ Flat vs. Nested data
21
21
********************
22
22
23
23
Before beginning to serialize data, it is important to identify or decide how the
24
- dataneeds to be structured during data serialization - flat or nested.
24
+ datashould to be structured during data serialization - flat or nested.
25
25
The differences in the two styles are shown in the below examples.
26
26
27
27
Flat style:
@@ -42,7 +42,7 @@ Nested style:
42
42
For more reading on the two styles, please see the discussion on
43
43
`Python mailing list <https://mail.python.org/pipermail/python-list/2010-October/590762.html >`__,
44
44
`IETF mailing list <https://www.ietf.org/mail-archive/web/json/current/msg03739.html >`__ and
45
- `here <https://softwareengineering.stackexchange.com/questions/350623/flat-or-nested-json-for-hierarchal-data >`__.
45
+ `in stackexchange <https://softwareengineering.stackexchange.com/questions/350623/flat-or-nested-json-for-hierarchal-data >`__.
46
46
47
47
****************
48
48
Serializing Text
@@ -57,7 +57,7 @@ If the data to be serialized is located in a file and contains flat data, Python
57
57
repr
58
58
----
59
59
60
- The repr method in Python takes a single object parameter and returns a printable representation of the input
60
+ The repr method in Python takes a single object parameter and returns a printable representation of the input:
61
61
62
62
..code-block ::python
63
63
@@ -79,7 +79,7 @@ ast.literal_eval
79
79
----------------
80
80
81
81
The literal_eval method safely parses and evaluates an expression for a Python datatype.
82
- Supported data types are: strings, numbers, tuples, lists, dicts, booleans and None.
82
+ Supported data types are: strings, numbers, tuples, lists, dicts, booleans, and None.
83
83
84
84
..code-block ::python
85
85
@@ -114,8 +114,8 @@ Simple example for writing:
114
114
writer.writerows(iterable)
115
115
116
116
117
- The module's contents, functions and examples can be found
118
- `here <https://docs.python.org/3/library/csv.html >`__.
117
+ The module's contents, functions, and examples can be found
118
+ `in the Python documentation <https://docs.python.org/3/library/csv.html >`__.
119
119
120
120
==================
121
121
YAML (nested data)
@@ -178,29 +178,29 @@ Example:
178
178
root= tree.getroot()
179
179
180
180
More documentation on using the `xml.dom ` and `xml.sax ` packages can be found
181
- `here <https://docs.python.org/3/library/xml.html >`__.
181
+ `in the Python XML library documentation <https://docs.python.org/3/library/xml.html >`__.
182
182
183
183
184
184
*******
185
185
Binary
186
186
*******
187
187
188
188
=======================
189
- Numpy Array (flat data)
189
+ NumPy Array (flat data)
190
190
=======================
191
191
192
- Python'sNumpy array can be used to serialize and deserialize data to and from byte representation.
192
+ Python'sNumPy array can be used to serialize and deserialize data to and from byte representation.
193
193
194
194
Example:
195
195
196
196
..code-block ::python
197
197
198
- import numpy as np
198
+ import NumPy as np
199
199
200
- # ConvertingNumpy array to byte format
200
+ # ConvertingNumPy array to byte format
201
201
byte_output= np.array([ [1 ,2 ,3 ], [4 ,5 ,6 ], [7 ,8 ,9 ] ]).tobytes()
202
202
203
- # Converting byte format back toNumpy array
203
+ # Converting byte format back toNumPy array
204
204
array_format= np.frombuffer(byte_output)
205
205
206
206