2016-11-26 4 views
1

ファイル内に行ごとにJSONオブジェクトとしてデータが格納されています。これをU-SQLスクリプトで抽出するには、どのような方法が良いですか?U-SQLでのJSON行の抽出

私はText Extractor(下のコードを参照)を使用していますが、JSONオブジェクトが大きくなり、文字列のサイズが128KBになっています。どんな助けでも感謝します。

サンプルデータ:

{ "prop1": "abc", "prop2": "xyz" } 
{ "prop1": "def", "prop2": "uvw" } 

U-SQL:

//Read (JSON Lines) line by line 
@dataAsStrings = 
    EXTRACT jsonObjStr string 
    FROM @INPUT_FILE 
    USING Extractors.Text(delimiter:'\n'); 

//Use the JsonTuple function to get the Json Token of the string so it can be parsed later with Json .NET functions 
@jsonify = SELECT Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple(jsonObjStr, "prop1", "prop2") AS rec FROM @dataAsStrings; 

//Extract the fields from the Json object. 
@json = SELECT 
      rec["prop1"] AS prop1, 
      rec["prop2"] AS prop2 
FROM @jsonify; 

答えて

0

おそらくJSON抽出処理で行指向の抽出を組み合わせた独自の "ハイブリッド" の抽出を記述する必要があります。

+0

どこでも完了しましたか? – Steve

+0

はい。 GitHubアセンブリにそのようなバージョンを追加することは、バックログにもあります。 –

+0

共有できるリンクはありますか? – Steve