Last active
March 12, 2017 16:17
-
-
Save ffr4nz/1866d2bc8c5befbefb34ab37cf4b0d50 to your computer and use it in GitHub Desktop.
Revisions
-
ffr4nz revised this gist
Jan 24, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ csv_doc_field = ['key1','key2'] # Field to be processed csv_doc = StringIO.StringIO() # 'False' file to use with CSV Writer json_doc = json.loads(json_doc) # Create JSON Object output = csv.writer(csv_doc) # Create CSV writer using StringIO file tt = list() # Field list for field in csv_doc_field: # Loop each field -
ffr4nz revised this gist
Jan 24, 2017 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,15 +7,15 @@ ''' json_doc = '{"key1":"value1","key2":"value2","key3":"value3"}' # JSON Document as Text csv_doc_field = ['key1','key2'] # Field to be processed csv_doc = StringIO.StringIO() # 'False' file to use with CSV Writer json_doc = json.loads(json_doc) # Create JSON Object output = csv.writer(csv_doc) # CSV writer creation using StringIO file tt = list() # Field list for field in csv_doc_field: # Loop each field tt.append(json_doc[field]) # Append each value processed output.writerow(tt) # Write row into StringIO file print csv_doc.getvalue() # Show result -> value1,value2 csv_doc.close() # Close StringIO file -
ffr4nz revised this gist
Jan 24, 2017 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,10 @@ json_doc = json.loads(json_doc) # Create JSON Object output = csv.writer(csv_doc) # CSV writer creation using StringIO file tt = list() # Field list for field in csv_doc_field: # Loop each field tt.append(json_doc[field]) # Append each value processed output.writerow(tt) # Write row into StringIO file print csv_doc.getvalue() # Show result -> value1,value2 csv_doc.close() # Close StringIO file -
ffr4nz created this gist
Jan 24, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import csv import json import StringIO ''' Create CSV row using CSV library from JSON Object using StringIO ''' json_doc = '{"key1":"value1","key2":"value2","key3":"value3"}' # JSON Document as Text csv_doc_field = ['key1','key2'] # Field to be processed csv_doc = StringIO.StringIO() # 'False' file to use with CSV Writer json_doc = json.loads(json_doc) # Create JSON Object output = csv.writer(csv_doc) # CSV writer creation using StringIO file tt = list() # Field list for field in csv_doc_field: # Loop each field tt.append(json_doc[field]) # Append each value processed output.writerow(tt) # Write row into StringIO file print csv_doc.getvalue() # Show result -> value1,value2 csv_doc.close() # Close StringIO file