<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Fully Parse and Extract Nested JSON from AuditData Column in CSV Using Notebook in Fabric in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4756774#M10744</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm working with a CSV file in Microsoft Fabric within a Notebook environment, and I'm running into issues parsing a complex JSON string stored in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AuditData&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column. This csv was downloaded from Microsoft Purview by the way, I am trying to programmatically use it to look at data.&lt;/P&gt;&lt;P&gt;Here’s an example of one row from the CSV:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RecordId,CreationDate,RecordType,Operation,UserId,AuditData,...
(RecordID),"2025-04-14T03:35:10.0000000Z",20,GenerateDataflowSasToken,(Random Email),"{""Id"":""(RandomID)"",""RecordType"":20,...,""WorkspaceId"":""(Random ID)"",""DataflowName"":""T_FINDING_DETAIL""}",...&lt;/LI-CODE&gt;&lt;P&gt;When I load this file using PySpark in Fabric, the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AuditData&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column only shows a truncated version of the JSON — usually just the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Id&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field. However, I need to extract other fields like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WorkspaceId,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DataflowName, etc.&lt;BR /&gt;&lt;BR /&gt;I have already tried reading the CSV with inferSchema=False, I tried cleaning the JSON string regexp_replace to fix escaped quotes, and using from_json() with a defined schema to parse the JSON.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark.sql.functions import col, from_json, regexp_replace
from pyspark.sql.types import StructType, StructField, StringType

df = spark.read.option("inferSchema", "false").option("header", "true").csv("path_to_file.csv")
df_cleaned = df.withColumn("AuditData", regexp_replace(col("AuditData"), '\\"', '"'))

audit_schema = StructType([
    StructField("Id", StringType()),
    StructField("WorkspaceId", StringType()),
    StructField("DataflowName", StringType())
])

df_parsed = df_cleaned.withColumn("AuditDataParsed", from_json(col("AuditData"), audit_schema))
df_parsed.select("AuditDataParsed.WorkspaceId").show()&lt;/LI-CODE&gt;&lt;P&gt;Despite this, the parsed column still only shows partial data or nulls. I suspect the JSON might be getting truncated or malformed during the read step, or maybe the schema is incomplete.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Questions:&lt;BR /&gt;1. What is the best way to ensure the full JSON string in AuditData is preservedand parsed correctly?&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;&lt;FONT size="4"&gt;&lt;FONT size="3"&gt;2. Is there a recommended way to dynamically infer the schema from a sample of the JSON in Fabric?&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;3. Could this be a limitation of the Fabric Notebook environment or Spark's CSV reader?&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Any help or guidance would be greatly appreciated!&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Thanks!&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jul 2025 15:12:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2025-07-08T15:12:25Z</dc:date>
    <item>
      <title>Fully Parse and Extract Nested JSON from AuditData Column in CSV Using Notebook in Fabric</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4756774#M10744</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm working with a CSV file in Microsoft Fabric within a Notebook environment, and I'm running into issues parsing a complex JSON string stored in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AuditData&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column. This csv was downloaded from Microsoft Purview by the way, I am trying to programmatically use it to look at data.&lt;/P&gt;&lt;P&gt;Here’s an example of one row from the CSV:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RecordId,CreationDate,RecordType,Operation,UserId,AuditData,...
(RecordID),"2025-04-14T03:35:10.0000000Z",20,GenerateDataflowSasToken,(Random Email),"{""Id"":""(RandomID)"",""RecordType"":20,...,""WorkspaceId"":""(Random ID)"",""DataflowName"":""T_FINDING_DETAIL""}",...&lt;/LI-CODE&gt;&lt;P&gt;When I load this file using PySpark in Fabric, the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AuditData&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column only shows a truncated version of the JSON — usually just the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Id&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field. However, I need to extract other fields like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WorkspaceId,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DataflowName, etc.&lt;BR /&gt;&lt;BR /&gt;I have already tried reading the CSV with inferSchema=False, I tried cleaning the JSON string regexp_replace to fix escaped quotes, and using from_json() with a defined schema to parse the JSON.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark.sql.functions import col, from_json, regexp_replace
from pyspark.sql.types import StructType, StructField, StringType

df = spark.read.option("inferSchema", "false").option("header", "true").csv("path_to_file.csv")
df_cleaned = df.withColumn("AuditData", regexp_replace(col("AuditData"), '\\"', '"'))

audit_schema = StructType([
    StructField("Id", StringType()),
    StructField("WorkspaceId", StringType()),
    StructField("DataflowName", StringType())
])

df_parsed = df_cleaned.withColumn("AuditDataParsed", from_json(col("AuditData"), audit_schema))
df_parsed.select("AuditDataParsed.WorkspaceId").show()&lt;/LI-CODE&gt;&lt;P&gt;Despite this, the parsed column still only shows partial data or nulls. I suspect the JSON might be getting truncated or malformed during the read step, or maybe the schema is incomplete.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Questions:&lt;BR /&gt;1. What is the best way to ensure the full JSON string in AuditData is preservedand parsed correctly?&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;&lt;FONT size="4"&gt;&lt;FONT size="3"&gt;2. Is there a recommended way to dynamically infer the schema from a sample of the JSON in Fabric?&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;3. Could this be a limitation of the Fabric Notebook environment or Spark's CSV reader?&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Any help or guidance would be greatly appreciated!&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Thanks!&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 15:12:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4756774#M10744</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-07-08T15:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Fully Parse and Extract Nested JSON from AuditData Column in CSV Using Notebook in Fabric</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4757701#M10774</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;Thanks for posting in Microsoft Fabric Community&amp;nbsp;sharing the detailed context.&lt;/P&gt;
&lt;P&gt;To extract fields or handle cases where certain parts of the JSON may be missing, consider using &lt;STRONG&gt;coalesce&lt;/STRONG&gt; while working with the parsed JSON column. This can help avoid issues when some fields are not always present in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A similar thread involved handling nested JSON in Fabric notebooks where using coalesce along with a properly defined schema allowed to extract fields safely, even when certain parts of the JSON were missing or null.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Data-Engineering/PySpark-Notebook-to-process-complex-JSON/m-p/3880282" target="_blank" rel="noopener"&gt;Solved: PySpark Notebook to process complex JSON - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You may refer to the discussion and apply the same pattern in your scenario.&lt;/P&gt;
&lt;P&gt;Hope this helps. Please reach out for further assistance.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 11:10:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4757701#M10774</guid>
      <dc:creator>v-veshwara-msft</dc:creator>
      <dc:date>2025-07-09T11:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Fully Parse and Extract Nested JSON from AuditData Column in CSV Using Notebook in Fabric</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4765193#M10957</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;Just wanted to check if the response provided was helpful. If further assistance is needed, please reach out.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jul 2025 11:42:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4765193#M10957</guid>
      <dc:creator>v-veshwara-msft</dc:creator>
      <dc:date>2025-07-16T11:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fully Parse and Extract Nested JSON from AuditData Column in CSV Using Notebook in Fabric</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4765547#M10963</link>
      <description>&lt;P&gt;Yes that thread was perfect. I appreciate your help!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jul 2025 15:11:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fully-Parse-and-Extract-Nested-JSON-from-AuditData-Column-in-CSV/m-p/4765547#M10963</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-07-16T15:11:54Z</dc:date>
    </item>
  </channel>
</rss>

