Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a file having several records, but few records are of same id, now need to separate records which have same id. After every same set of records we have ENDORDER as keyword, this can be taken into consideration to split the file. Can someone suggest on it.
Hi
Can you take a look at tUniqueRow component? This component is used to get the unique rows and duplicated rows. If it does not meet your need, please describe your requirement with some example data.
Regards
Shong
Thanks Shong, but here is no duplicate record. We have a file which has several orders and now we need to split file into each order and each order ends with ENDORDER and then need to convert it to json file.
e.g.
A|1|2|3|4
B|1|2|3|4|5|6
C|1|2|3
D|1|2|3|4|5
ENDORDER
A|1|2|3|4
B|1|2|3|4|5|6
B|1|2|3|4|5|6
C|1|2|3
C|1|2|3
C|1|2|3
D|1|2|3|4|5
ENDORDER
A|1|2|3|4
B|1|2|3|4|5|6
B|1|2|3|4|5|6
B|1|2|3|4|5|6
B|1|2|3|4|5|6
C|1|2|3
C|1|2|3
D|1|2|3|4|5
now it has 3 orders as below
A|1|2|3|4
B|1|2|3|4|5|6
C|1|2|3
D|1|2|3|4|5,
A|1|2|3|4
B|1|2|3|4|5|6
B|1|2|3|4|5|6
C|1|2|3
C|1|2|3
C|1|2|3
D|1|2|3|4|5,
A|1|2|3|4
B|1|2|3|4|5|6
B|1|2|3|4|5|6
B|1|2|3|4|5|6
B|1|2|3|4|5|6
C|1|2|3
C|1|2|3
D|1|2|3|4|5
Also please suggest how to convert such files in json/xml. A,B,C,D are having different schema and can come multiple/no times in an order.
Thanks in advance.
Can anyone please suggest on it.
Hi
Here is a scenario showing how to split the file to multiple text files.
This job will split the file to multiple text files, like filename1.txt, filename2.txt etc.
If you want to generate XML or Json file, you need to use a tFileList to iterate these text files in next step. Can you show an example of XML/Json file you want to generate?
Regards
Shong
Thank you very much Shong, The files which we separated from the above need to convert into a XML/JSON message.
e.g.
A|1|2|3|4
B|1|2|3|4|5|6
B|1|2|3|4|5|6
C|1|2|3
C|1|2|3
C|1|2|3
D|1|2|3|4|5
here row starting from A,B,C,D are having different schema and B,C,D can come in multiple/no times. Hope this clarifies the question.
@Shicong Hong Could you please suggest on it.
What does the XML/Json file look like? There is no header columns in the file, what will be the element name in the XML/Json file?
Currently I don't have any output file xsd, ony doing POC where we need to convert a flat file like above into an XML file. there will be 4 types of records A, B, C, D where B,C,D can come multiple/no times as below. A,B,C,D are having different schema not dynamic schema means A will have fix number of fields and so on on.
A|1|2|3|4
B|1|2|3|4|5|6
B|1|2|3|4|5|6
C|1|2|3
C|1|2|3
C|1|2|3
D|1|2|3|4|5
Hope you get the requirement.@Shicong Hong
We usually use tAdvancedFileOutputXML to generate a XML file. There is no header columns in your file, I just show a simple example, set the schema to have 7 columns, c1,c2...c7.
It will generate a XML file as below:
<?xml version="1.0" encoding="ISO-8859-15"?>
<rootTag>
<c1 value="A">
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5>4</c5>
<c6/>
<c7/>
</person>
</c1>
<c1 value="B">
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5>4</c5>
<c6>5</c6>
<c7>6</c7>
</person>
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5>4</c5>
<c6>5</c6>
<c7>6</c7>
</person>
</c1>
<c1 value="C">
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5/>
<c6/>
<c7/>
</person>
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5/>
<c6/>
<c7/>
</person>
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5/>
<c6/>
<c7/>
</person>
</c1>
<c1 value="D">
<person>
<c2>1</c2>
<c3>2</c3>
<c4>3</c4>
<c5>4</c5>
<c6>5</c6>
<c7/>
</person>
</c1>
</rootTag>