0

Given an S3 bucket called my-bucket that includes a bucket with key named my-object, is it possible to retrieve values from the object if the object value consists of a list of key/value pairs?

i.e. if my-object contains a file with the following key/value pairs:

foo: 20, 
bar: 54, 
baz: 12

Is it possible to just retrieve the value of 'foo' by its key using the SDK for Java?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
cvoep28
  • 423
  • 5
  • 9
  • 21

1 Answers1

3

You could use Amazon S3 Select to parse the values.

However, the format of your file isn't great because:

  • Some lines have a comma, others do not
  • It has excess spaces in the file

Let's say you had this format instead:

foo:20
bar:54
baz:12

You could then query it with S3 Select, using the colon as a separator:


Amazon S3 Select


To do this in Java, see: Selecting Content from Objects Using the SDK for Java - Amazon Simple Storage Service

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470