Rendering(Formatting) the data¶
You might want to do custom rendering on your data obtained. row_renderer was added since version 0.2.3. Here is how you can use it.
Let’s assume the following file:
>>> import datetime
>>> from pyexcel_io import save_data
>>> data = [
... [1, 21, 31],
... [2, 22, 32],
... [3, 23, 33]
... ]
>>> save_data("your_file.csv", data)
And let’s read them back:
>>> from pyexcel_io import get_data
>>> data = get_data("your_file.csv")
>>> data['your_file.csv']
[[1, 21, 31], [2, 22, 32], [3, 23, 33]]
And you may want use row_renderer to customize it to string:
>>> def my_renderer(row):
... return [str(element) for element in row]
>>> data = get_data("your_file.csv", row_renderer=my_renderer)
>>> data['your_file.csv']
[['1', '21', '31'], ['2', '22', '32'], ['3', '23', '33']]