29 Nov Convert CSV to XML in Alteryx
Extensible Markup Language(XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. XML uses a series of simple tags to describe data and these tags can be created in an easier way.
CSV is a simple file format used to store tabular data such as a database or spreadsheet. A CSV file stores data in a structure that can be read and written by a wide range of several spreadsheet software packages.
In this article, I’ll walk you through how to convert CSV to XML in Alteryx. Let’s get right in.
We will use some tools in Alteryx to achieve our aim.
- The first tool we will be using in this conversion is the input tool which shows an input file. This is where we will pass in our sample data.
- The second tool is the Record ID which will be used to number the data sequentially. We can call this an index.
- The third tool is the Transpose which we will use to change the data orientation from vertical to horizontal.
Add regex to remove spaces in the Name column using the Formula tool. After then, use the select tool to pick the fields and rename the datatype from string to integer.
We will use the formula tool again to perform two different calculations for the name tag. Afterward, add both name tags and re-index using the Record ID tool.
Use the text input tool to add xml initiation line such as this; <?xml version=”1.0″ encoding=”UTF-8″?>,and it will be passed to the data. The union tool will then be parsed in to connect different data coming from the workflow.
The summation tool coming from the Record ID tool will be used to group the data using the name column.
The Append Field tool as shown below will be used to append some of the fields i.e. ColumnNumber to each of the fields(XmlLine, RecordId, Level). The other tools used include the Multi-Row Formula tool, the formula tool, and then parsing the join, union tool and summarizing them to obtain our XML file.
We’ll then use the output tool in viewing our results.
No Comments