@@ -26,7 +26,7 @@ Now you might be wondering why another library when there are already a few impl
26
26
* The implementation achieves 100% test coverage.
27
27
* It follows Pythonic principles, resulting in clean and readable code.
28
28
* It adds some cool innovative features such as conditions or error handling and an even more declarative look.
29
- * It provides loaders for various data sources such as CSV, JSON and XML files.
29
+ * It provides loaders for various data sources such as CSV, JSON, XML and YAML files.
30
30
31
31
Let's take a look at a small example:
32
32
@@ -213,15 +213,15 @@ Stream.concat(Stream.of([1, 2]), Stream.of([3, 4]))
213
213
214
214
Creates a new Stream from multiple Streams. Order doesn't change.
215
215
216
- ## Use loaders: Load data from CSV, JSON and XML files in just one line
216
+ ## Use loaders: Load data from CSV, JSON, XML and YAML files in just one line
217
217
218
- PyStreamAPI offers a convenient way to load data from CSV, JSON and XML files. Like that you can start processing your
218
+ PyStreamAPI offers a convenient way to load data from CSV, JSON, XML and YAML files. Like that you can start processing your
219
219
files right away without having to worry about reading and parsing the files.
220
220
221
221
You can import the loaders with:
222
222
223
223
``` python
224
- from pystreamapi.loaders import csv, json, xml
224
+ from pystreamapi.loaders import csv, json, xml, yaml
225
225
```
226
226
Now you can use the loaders directly when creating your Stream:
227
227
@@ -253,14 +253,30 @@ pip install streams.py[xml_loader]
253
253
Afterward, you can use the XML loader like this:
254
254
255
255
``` python
256
- Stream.of(xml(" data.xml" ))
257
- .map(lambda x : x.attr1)
256
+ Stream.of(xml(" data.xml" )) \
257
+ .map(lambda x : x.attr1) \
258
258
.for_each(print )
259
259
```
260
260
261
261
The access to the attributes is using a node path syntax. For more details on how to use the node path syntax, please
262
262
refer to the [ documentation] ( https://pystreamapi.pickwicksoft.org/reference/data-loaders ) .
263
263
264
+ For YAML:
265
+
266
+ In order to use the YAML loader, you need to install the optional yaml dependency:
267
+
268
+ ``` bash
269
+ pip install streams.py[yaml_loader]
270
+ ```
271
+
272
+ Afterward, you can use the YAML loader like this:
273
+
274
+ ``` python
275
+ Stream.of(yaml(" data.yaml" )) \
276
+ .map(lambda x : x.attr1) \
277
+ .for_each(print )
278
+ ```
279
+
264
280
## API Reference
265
281
For a more detailed documentation view the docs on GitBook: [ PyStreamAPI Docs] ( https://pystreamapi.pickwicksoft.org/ )
266
282
0 commit comments