Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi.
I am creating on converting CSV file to JSON file job.
My CSV Format:
Product,Price,Quantity "ABC",100,10 "DEF",200,20
Json file format I need:
{ "app" : 1, "records" : [ { "Product" : { "value" : "ABC"}, "Price" : { "value" : 100}, "Quantity" : { "value" : 10} }, { "Product" : { "value" : "DEF"}, "Price" : { "value" : 200}, "Quantity" : { "value" : 20} } ] }
I have completed this:
{ "records" : [ { "Product" : "ABC", "Price" : 100, "Quantity" : 10 }, { "Product" : "DEF", "Price" : 200, "Quantity" : 20 } ] }
How can I add an "app" property to the route and include "value" property?
The “1” property data can be a static value.
My job setting (sorry, it's not the English version.):
All schemas are built-in and default settings.
Thank you.
OK, Let's do this. You can achieve this by doing it in two stages.
Build a job that looks like the one below. In the first tWriteJSONField you create a JSON object for each row (pay attention to all the settings!).
In a tMap you simply add a new column called "app" and map the output of the previous step to a column called "records".
Then move the output into another tWriteJSONField component and configure it as follows (the output has just one column named "content"):
Finally, store your output in a file (or do whatever you want to do with it.
When I put the following input into the tFixedFlowInput (Product is a String, Price is an Integer, Quantity is an Integer - of course you could also use a CSV file as input)
Product,Price,Quantity "ABC",100,10 "DEF",200,20
I get the following output
{"app":1,"records":[{"product":{"value":"ABC"},"price":{"value":100},"quantity":{"value":10}},{"product":{"value":"DEF"},"price":{"value":200},"quantity":{"value":20}}]}
I hope this helps.
OK, Let's do this. You can achieve this by doing it in two stages.
Build a job that looks like the one below. In the first tWriteJSONField you create a JSON object for each row (pay attention to all the settings!).
In a tMap you simply add a new column called "app" and map the output of the previous step to a column called "records".
Then move the output into another tWriteJSONField component and configure it as follows (the output has just one column named "content"):
Finally, store your output in a file (or do whatever you want to do with it.
When I put the following input into the tFixedFlowInput (Product is a String, Price is an Integer, Quantity is an Integer - of course you could also use a CSV file as input)
Product,Price,Quantity "ABC",100,10 "DEF",200,20
I get the following output
{"app":1,"records":[{"product":{"value":"ABC"},"price":{"value":100},"quantity":{"value":10}},{"product":{"value":"DEF"},"price":{"value":200},"quantity":{"value":20}}]}
I hope this helps.
Thanks for reply.
I tried it.
But, "Output Column" is empty.
Is something wrong?
tFixedFlowInput settings:
tFixedFlowInput schema settings:
Result of confirming tFixedFlowInput output with tLogRow(Table mode):
[statistics] connecting to socket on port 3712 [statistics] connected .--------+-----+--------. | tLogRow_1 | |=-------+-----+-------=| |Product |Price|Quantity| |=-------+-----+-------=| |Product1|100 |10 | |Product2|200 |20 | '--------+-----+--------' [statistics] disconnected
Thanks.
Click on "Edit Schema" in tWriteJSONField and add the missing output column on the right side?
Oh, I did not...
I set it like this now:
Then, three items will be displayed.
How do I display content only?
Thank you.
You will have to remove the three columns just from the right side of the schema and just add a single column there (e.g. "content"). Do not use the arrows in the middle to move columns between the schemas.
Thank you very much.
It is almost completed, but I want you to help at the end.
When setting to your answers, the final output looks like this.
{"app":1,"records":{"Product":{"value":"Product1"},"Price":{"value":100},"Quantity":{"value":10}}} {"app":1,"records":{"Product":{"value":"Product2"},"Price":{"value":200},"Quantity":{"value":20}}}
I've checked your screenshots many times, but I don't know what's wrong.
tMap mapping:
tMap component setting:
tWriteJSONField2 schema setting:
tWriteJSONField2 setting:
tWriteJSONField2 JSON tree setting:
Thank you.
You are missing the "Group By" settings in tWriteJSONField_2.