ADF Parsing JSOn column values in csv file

Nandan Hegde 36,146 Reputation points MVP Volunteer Moderator
2021-07-13T13:20:29.013+00:00

Hey,
I have a CSV file with below format :

c1,c2,c3
1,ABC,"{'InvestigationName': None, 'Status': None, 'ProcessedBySentinel': 2}"
2,XYZ,"{'InvestigationName': None, 'Status': None, 'ProcessedBySentinel': 1}"
3,MNC,"{'InvestigationName': 1234, 'Status': None, 'ProcessedBySentinel': 1}"

where column c3 is of JSON format. I need to parse that Json value to different columns and generate a CSV file. I am using parse functionlaity :

But I am getting the below error:

StructType(StructField(InvestigationName,StringType,true), StructField(Status,StringType,true)) (of class org.apache.spark.sql.types.StructType)

for more details on the issue:
https://stackoverflow.com/questions/68362992/parse-json-column-value-in-csv-file

Can someone point out what I am doing wrong?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
{count} vote

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,236 Reputation points
    2021-07-13T22:09:39.597+00:00

    @Nandan Hegde we found the(?) cause. There was a setting we missed.

    In the Parse Settings, below format, there is Json settings. It started out minimized and set to "Document per line". After I changed it to "Single document", things started to work.

    114246-image.png

    Update:
    There was another thing I did. I made derived column using

    replace(replace(c3,"'",'"'),'None','"non"')  
    

    I am testing whether one or both of these replaces are necessary.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.