esProc Joins a Structured Text file with a JSON File

structure.txt is a tab-separated structured text file. json.txt contains non-structured JSON strings. We need to join the two files to create a new file result.txt. The original data is as follows.

structure.txt

esProc_text_structure_json_1

Json.txt

esProc_text_structure_json_2

Result.txt

esProc_text_structure_json_3

esProc will first import json.txt as a structured table sequence and then join it with structure.txt. The code is as follows:

esProc_text_structure_json_4

A1: Import the JSON file into the memory as a table sequence.
A2: Retrieve name column and cluster column from it. #1 represents the first column. Result is as follows:

esProc_text_structure_json_5

A3: Split cluster column into two parts, name them key and value respectively and thus generate a structured data object. Result is as follows:

esProc_text_structure_json_6

A4: Import the structured text file.

A5: Perform join operation. _2 represents A4’s second column. Result is as follows:

esProc_text_structure_json_7

 

A6,B7: Retrieve desired columns and export them to result.txt.

Advertisements

About datathinker

a technical consultant on Database performance optimization, Database storage expansion, Off-database computation. personal blog at: datakeywrod, website: raqsoft
This entry was posted in esProc/R/Python/Perl, Structured Data Process and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s