-
-
Notifications
You must be signed in to change notification settings - Fork 2
incendium.dataset.to_xml
César Román edited this page Apr 30, 2024
·
17 revisions
Return a string XML representation of the Dataset.
Args:
- dataset (
Dataset
): The input dataset. - root (
str
): The value of the root. If not provided, it defaults to "root". Optional. - element (
str
): The value of the row. If not provided, it defaults to "row". Optional.
New in 2022.3.2
- indent (
str
): Current indentation. If not provided, it defaults to "\t". Optional.
Returns:
-
str
: The string XML representation of the dataset.
None.
from __future__ import print_function
import incendium.dataset
import system.dataset
def get_dataset():
# Generate the Rows
rows = []
for x in range(10):
row = ["row {}".format(x), x + 15]
rows.append(row)
# Generate the DataSet
headers = ["row_id", "value"]
return system.dataset.toDataSet(headers, rows)
# Get the Dataset
ds = get_dataset()
print(incendium.dataset.to_xml(ds, indent=" "))
Output:
<root>
<row>
<row_id>row 0</row_id>
<value>15</value>
</row>
<row>
<row_id>row 1</row_id>
<value>16</value>
</row>
<row>
<row_id>row 2</row_id>
<value>17</value>
</row>
<row>
<row_id>row 3</row_id>
<value>18</value>
</row>
<row>
<row_id>row 4</row_id>
<value>19</value>
</row>
<row>
<row_id>row 5</row_id>
<value>20</value>
</row>
<row>
<row_id>row 6</row_id>
<value>21</value>
</row>
<row>
<row_id>row 7</row_id>
<value>22</value>
</row>
<row>
<row_id>row 8</row_id>
<value>23</value>
</row>
<row>
<row_id>row 9</row_id>
<value>24</value>
</row>
</root>