<s> from __future__ import division , print_function , absolute_import <EOL> import petl as etl <EOL> data = '''<STR_LIT>''' <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( data ) <EOL> table1 = etl . fromjson ( '<STR_LIT>' ) <EOL> table1 <EOL> import petl as etl <EOL> dicts = [ { "<STR_LIT:foo>" : "<STR_LIT:a>" , "<STR_LIT:bar>" : <NUM_LIT:1> } , <EOL> { "<STR_LIT:foo>" : "<STR_LIT:b>" , "<STR_LIT:bar>" : <NUM_LIT:2> } , <EOL> { "<STR_LIT:foo>" : "<STR_LIT:c>" , "<STR_LIT:bar>" : <NUM_LIT:2> } ] <EOL> table1 = etl . fromdicts ( dicts ) <EOL> table1 <EOL> import petl as etl <EOL> table1 = [ [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] , <EOL> [ '<STR_LIT:a>' , <NUM_LIT:1> ] , <EOL> [ '<STR_LIT:b>' , <NUM_LIT:2> ] , <EOL> [ '<STR_LIT:c>' , <NUM_LIT:2> ] ] <EOL> etl . tojson ( table1 , '<STR_LIT>' , sort_keys = True ) <EOL> print ( open ( '<STR_LIT>' ) . read ( ) ) <EOL> import petl as etl <EOL> table1 = [ [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] , <EOL> [ '<STR_LIT:a>' , <NUM_LIT:1> ] , <EOL> [ '<STR_LIT:b>' , <NUM_LIT:2> ] , <EOL> [ '<STR_LIT:c>' , <NUM_LIT:2> ] ] <EOL> etl . tojsonarrays ( table1 , '<STR_LIT>' ) <EOL> print ( open ( '<STR_LIT>' ) . read ( ) ) </s>
