0

Reading CSV file with no headers, however the output is missing the first line which is not header in the CSV file.

trying to convert csv to json but upon following below steps its working in online data weave editor but not in studio.

https://help.mulesoft.com/s/article/In-DataWeave-reading-CSV-with-header-false-causes-the-missing-first-line-in-the-output

Input CSV:

RSK,IP,PI,PI2016007219,PI,Tug & Barge Fleet Protection & Indemnity~73835~02/20/2015,,Open,90300815,D,20170616,,S17616R,R04,210.91,99,,C,james kristovich,1550811,01,a010V00000oIjJEQA0
RSK,IP,PI,PI2016007220,PI,Tug & Barge Fleet Protection & Indemnity~73835~02/20/2015,,Open,90300815,D,20170616,,S17616R,R04,210.91,99,,C,james kristovich,1550811,01,a010V00000oIjJEQA0

Expected Output:

[
  {
    "Source Abbr": "RSK",
    "Transaction Type": "IP",
    "Claim Type": "PI",
    "Claim Number": "PI2016007219",
    "Coverage Line": "PI",
    "Policy": "Tug & Barge Fleet Protection & Indemnity~73835~02/20/2015",
    "Policy Section": "",
    "Claim Status": "Open",
    "Bus. Entity": "90300815",
    "Invoice Type": "D",
    "Date of Invoice": "20170616",
    "Invoice Due Date": "",
    "Invoice Number": "S17616R",
    "Transaction Code": "R04",
    "Amount": "210.91",
    "Transaction Comment Type": "99",
    "Transaction Comment": "",
    "Check Comment Type": "C",
    "Check Comment": "james kristovich",
    "Payee CVIF Number": "1550811",
    "Payee CVIF Location": "01",
    "Riskonnect UID": "a010V00000oIjJEQA0"
  },
  {
    "Source Abbr": "RSK",
    "Transaction Type": "IP",
    "Claim Type": "PI",
    "Claim Number": "PI2016007220",
    "Coverage Line": "PI",
    "Policy": "Tug & Barge Fleet Protection & Indemnity~73835~02/20/2015",
    "Policy Section": "",
    "Claim Status": "Open",
    "Bus. Entity": "90300815",
    "Invoice Type": "D",
    "Date of Invoice": "20170616",
    "Invoice Due Date": "",
    "Invoice Number": "S17616R",
    "Transaction Code": "R04",
    "Amount": "210.91",
    "Transaction Comment Type": "99",
    "Transaction Comment": "",
    "Check Comment Type": "C",
    "Check Comment": "james kristovich",
    "Payee CVIF Number": "1550811",
    "Payee CVIF Location": "01",
    "Riskonnect UID": "a010V00000oIjJEQA0"
  }
]

Logic:

%dw 2.0
output application/json
var keys= [
      "Source Abbr",
      "Transaction Type",
      "Claim Type",
      "Claim Number",
      "Coverage Line",
      "Policy",
      "Policy Section",
      "Claim Status",
      "Bus. Entity",
      "Invoice Type",
      "Date of Invoice",
      "Invoice Due Date",
      "Invoice Number",
      "Transaction Code",
      "Amount",
      "Transaction Comment Type",
      "Transaction Comment",
      "Check Comment Type",
      "Check Comment",
      "Payee CVIF Number",
      "Payee CVIF Location",
      "Riskonnect UID"
    ]
---
 payload map (
        $ mapObject ((value, key, index) ->
            (keys[index]) : value
         )
    )

In Online Dataweave editor, logic is working as below: Online Dataweave editor logic

Same logic is not working in studio v7.13. Size of payload is 1 instead of 2

Same logic is not working in studio v7.13

Rob
  • 14,746
  • 28
  • 47
  • 65
  • 2
    This is a duplicate question. Does this answer your question? [Reading CSVs w/o Headers in DataWeave 2.0](https://stackoverflow.com/questions/57778065/reading-csvs-w-o-headers-in-dataweave-2-0) – aled Feb 19 '23 at 11:14

0 Answers0