Read and print a row.

## Code sample

### C#


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    using https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.Common.V2/latest/Google.Cloud.Bigtable.Common.V2.html;
    using https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.html;
    using System;
    using System.Linq;
    using System.Threading.Tasks;



    namespace Reads
    {
        public class ReadSnippets
        {
            // Write your code here.
            // ...
            public string PrintRow(https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Row.html row)
            {
                string result = $"Reading data for {row.https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Row.html#Google_Cloud_Bigtable_V2_Row_Key.ToStringUtf8()}\n";
                foreach (https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Family.html family in row.https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Row.html#Google_Cloud_Bigtable_V2_Row_Families)
                {
                    result += $"Column Family {family.Name}\n";

                    foreach (https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Column.html column in family.Columns)
                    {
                        foreach (https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Cell.html cell in column.https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Column.html#Google_Cloud_Bigtable_V2_Column_Cells)
                        {
                            result += $"\t{column.Qualifier.ToStringUtf8()}: {cell.https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.Value.html.ToStringUtf8()} @{cell.TimestampMicros} {cell.Labels}\n";
                        }
                    }
                }
                result += "\n";
                Console.WriteLine(result);
                return result;
            }
        }
    }

### Go


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    func printRow(w io.Writer, row bigtable.Row) {
    	fmt.Fprintf(w, "Reading data for %s:\n", row.Key())
    	for columnFamily, cols := range row {
    		fmt.Fprintf(w, "Column Family %s\n", columnFamily)
    		for _, col := range cols {
    			qualifier := col.Column[strings.IndexByte(col.Column, ':')+1:]
    			fmt.Fprintf(w, "\t%s: %s @%d\n", qualifier, col.Value, col.Timestamp)
    		}
    	}
    	fmt.Fprintln(w)
    }

### Java


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).


    import static com.google.cloud.bigtable.data.v2.models.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Filters.html.FILTERS;

    import com.google.api.gax.rpc.https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStream.html;
    import com.google.cloud.bigtable.data.v2.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient.html;
    import com.google.cloud.bigtable.data.v2.models.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Filters.html;
    import com.google.cloud.bigtable.data.v2.models.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Query.html;
    import com.google.cloud.bigtable.data.v2.models.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Row.html;
    import com.google.cloud.bigtable.data.v2.models.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.RowCell.html;
    import com.google.cloud.bigtable.data.v2.models.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.TableId.html;
    import java.io.IOException;

    public class Reads {

      // Write your code here.
      // ...

      private static void printRow(https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Row.html row) {
        System.out.printf("Reading data for %s%n", row.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Row.html#com_google_cloud_bigtable_data_v2_models_Row_getKey__().toStringUtf8());
        String colFamily = "";
        for (https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.RowCell.html cell : row.https://docs.cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.models.Row.html#com_google_cloud_bigtable_data_v2_models_Row_getCells__()) {
          if (!cell.getFamily().equals(colFamily)) {
            colFamily = cell.getFamily();
            System.out.printf("Column Family %s%n", colFamily);
          }
          System.out.printf(
              "\t%s: %s @%s%n",
              cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
        }
        System.out.println();
      }
    }

### PHP


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    // Helper function for printing the row data
    function print_row(string $key, array $row): void
    {
        printf('Reading data for row %s' . PHP_EOL, $key);
        foreach ((array) $row as $family => $cols) {
            printf('Column Family %s' . PHP_EOL, $family);
            foreach ($cols as $col => $data) {
                for ($i = 0; $i < count($data); $i++) {
                    printf(
                        "\t%s: %s @%s%s" . PHP_EOL,
                        $col,
                        $data[$i]['value'],
                        $data[$i]['timeStamp'],
                        $data[$i]['labels'] ? sprintf(' [%s]', $data[$i]['labels']) : ''
                    );
                }
            }
        }
        print(PHP_EOL);
    }

### Python


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    def print_row(row):
        from google.cloud._helpers import _datetime_from_microseconds

        print("Reading data for {}:".format(row.row_key.decode("utf-8")))
        last_family = None
        for cell in row.cells:
            if last_family != cell.family:
                print("Column Family {}".format(cell.family))
                last_family = cell.family

            labels = " [{}]".format(",".join(cell.labels)) if len(cell.labels) else ""
            print(
                "\t{}: {} @{}{}".format(
                    cell.qualifier.decode("utf-8"),
                    cell.value.decode("utf-8"),
                    _datetime_from_microseconds(cell.timestamp_micros),
                    labels,
                )
            )
        print("")

### Ruby


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    # Import google bigtable client lib
    require "google/cloud/bigtable"
    # Write your code here.
    # ...
    def print_row row
      puts "Reading data for #{row.key}:"

      row.cells.each do |column_family, data|
        puts "Column Family #{column_family}"
        data.each do |cell|
          labels = !cell.labels.empty? ? " [#{cell.labels.join ','}]" : ""
          puts "\t#{cell.qualifier}: #{cell.value} @#{cell.timestamp}#{labels}"
        end
      end
      puts "\n"
    end

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=bigtable).