Ich kann einige Daten mit Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple abrufen, aber ich habe Probleme, die gesamte Datei einzuebnen.Wie glätte ich JSON zu CSV mit USQL
Hier ist das Dateiformat Ich arbeite mit:
{
"SourceUrl":"http://www.unittest.org/test.html",
"Title":"Unit Test File",
"Guest":"Unit Test Guest",
"PublishDate":"2017-05-15T00:00:00",
"TranscriptionSections":[
{
"SectionStartTime":"00:00:03",
"Sentences":[
{
"Text":"Intro."
},
{
"Text":"Sentence one"
},
{
"Text":"Sentence two"
}
]
},
{
"SectionStartTime":"00:04:46",
"Sentences":[
{
"Text":"Sentence three"
},
{
"Text":"Sentence four"
}
]
}
],
"Categories":null
}
Was ich versuche pro Text ist eine Reihe zu bekommen (5 von ihnen), es ist ‚SectionStartTime‘ und alle Top-Level-Eigenschaften, einschließlich (‘ PublishDate ',' Gast '...).
Bisher kann ich eine Zeile pro 'SectionStartTime' erhalten diese mit:
USE econosphere;
REFERENCE ASSEMBLY [Newtonsoft.Json];
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];
DECLARE @in string="adl://abc.azuredatalakestore.net/data/20170515UnitTest.json";
DECLARE @out
string="adl://abc.azuredatalakestore.net/processed/20170515UnitTest.csv";
@ep = EXTRACT
Title string,
SourceUrl string,
Guest string,
PublishDate DateTime,
TranscriptionSections string
FROM @in
USING new Microsoft.Analytics.Samples.Formats.Json.JsonExtractor();
@epAndTransctripts =
SELECT Title,
SourceUrl,
Guest,
PublishDate,
Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple(TranscriptionSections).Values AS TranscriptionSections_arr
FROM @ep;
@all =
SELECT
Title,
SourceUrl,
Guest,
PublishDate,
Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple(sects)["SectionStartTime"] AS TranscriptionSectionTimes
FROM @epAndTransctripts
CROSS APPLY
EXPLODE(TranscriptionSections_arr) AS t(sects);
OUTPUT @all
TO @out
USING Outputters.Csv();