Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
HI guys,
I'm writing a job which will call an API for an eCommerce site which will return all unprocessed orders. I then need to write this information to a CSV file (1 CSV per order). The CSV should contain an initial row with header information (eg. customer & address info) and then a line per order item.
I've currently managed to extract the information using several tExtractJSONFields but now I'm struggling to find a way to create the required CSV.
I have also tried using ThMap with no success, I would love to hear your thoughts on the way best to achieve this and if I'm completely in the wrong ballpark.
API Response:
{
"message": "Fetched order(s)",
"data": [
{
"orderId": 1,
"orderNumber": "ORDER0001",
"createdAt": "2019-08-13T14:58:07+01:00",
"deliveryAddress": {
"id": 1,
"town": "dasd",
"country": "ada",
"lastName": "asdasd",
"postcode": "asda",
"createdAt": "2019-08-13T14:57:47+01:00",
"firstName": "sakdmsad",
"updatedAt": "2019-08-13T14:57:47+01:00",
"thoroughfare": "adasd",
"houseNameNumber": "12",
"isDefaultBillingAddress": true,
"isDefaultShippingAddress": true
},
"orderLines": [
{
"orderLineId": 1,
"idealUin": "DELIVERY",
"supplierUin": "DELIVERY",
"quantity": 2,
"unitPrice": "5.00"
},
{
"orderLineId": 2,
"idealUin": "product0004",
"supplierUin": "product0004",
"quantity": 2,
"unitPrice": "5.00"
}
]
},
{
"orderId": 2,
"orderNumber": "ORDER0002",
"createdAt": "2019-08-13T14:58:07+01:00",
"deliveryAddress": {
"id": 1,
"town": "dasd",
"country": "ada",
"lastName": "asdasd",
"postcode": "asda",
"createdAt": "2019-08-13T14:57:47+01:00",
"firstName": "sakdmsad",
"updatedAt": "2019-08-13T14:57:47+01:00",
"thoroughfare": "adasd",
"houseNameNumber": "12",
"isDefaultBillingAddress": true,
"isDefaultShippingAddress": true
},
"orderLines": [
{
"orderLineId": 1,
"idealUin": "DELIVERY",
"supplierUin": "DELIVERY",
"quantity": 2,
"unitPrice": "5.00"
},
{
"orderLineId": 2,
"idealUin": "product0005",
"supplierUin": "product0005",
"quantity": 2,
"unitPrice": "5.00"
}
]
}
]
}
Talend job currently:
An example of the information returned in the tLogRow is below;
.-----------+------------+---------------+--------+---------+----------+---------------+---------------+---------------------+--------------+------------+------------------+-------+------------+---------------------------------------------------------. | tLogRow_3 | |=----------+------------+---------------+--------+---------+----------+---------------+---------------+---------------------+--------------+------------+------------------+-------+------------+--------------------------------------------------------=| |orderLineId|idealUin |supplierUin |quantity|unitPrice|firstName |lastName |houseNameNumber|thoroughfare |town |postcode |country |orderId|orderNumber |createdAt | |=----------+------------+---------------+--------+---------+----------+---------------+---------------+---------------------+--------------+------------+------------------+-------+------------+--------------------------------------------------------=| |1 |PRODUCT0001 |PRODUCT0001 |1 |5.00 |["Test"] |["Test"] |["11"] |["West Road"] |[London"] |["NE1 2DW"] |["UK"] |[1] |["ORDER0001"] |["2019-07-26T09:39:21+00:00"]|
Thanks in advance
Hello,
Is there any update for your issue?
Best regards
Sabrina
Hi Sabrina,
Due to a lack of support we had to totally bypass Talend and just change the data from the source, so it was received in a csv format rather than JSON.
We have experience in solving problems JSON data.
If you need support, feel free to ask for help - https://whidegroup.com/