Database Reference
In-Depth Information
for i in xrange(0, len(fields)):
cell = row['f'][i]
field = fields[i]
print "%s: %s " % (field['name'], cell['v']),
print ''
Most of the Python examples in this topic will look similar if translated
into other programming languages. However, statically typed languages,
such as Java, make it more difficult to write code where the types are not
known ahead of time. Because the code is much different from the Python
version, we show the Java code in Listing 5.2 to iterate through the rows in a
Tabledata.list() response and print it as JSON with the fields labeled.
Listing 5.2 : Parsing TableData list nested responses from Java
(ResultReader.java)
import com.google.api.client.util.Data;
import
com.google.api.services.bigquery.model.GetQueryResultsResponse;
import
com.google.api.services.bigquery.model.QueryResponse;
import
com.google.api.services.bigquery.model.TableCell;
import
com.google.api.services.bigquery.model.TableDataList;
import
com.google.api.services.bigquery.model.TableFieldSchema;
import com.google.api.services.bigquery.model.TableRow;
import
com.google.api.services.bigquery.model.TableSchema;
import java.io.PrintStream;
import java.util.List;
import java.util.Map;
/**
* Translates f / v results from BigQuery table
listing or query results
* into {field1 : value1, field2 : value2, …} JSON
output.
*/
 
 
Search WWH ::




Custom Search