Read in avro file with boto3 and convert to string (Python)
<p>I'm using boto3 to read in an avro file from my s3 bucket.
However, I'm stuck on how to actually convert the avro to a string.</p>

<pre><code>avro_file = file_from_s3.get()['Body'].read()
</code></pre>

<p>After getting to this step, I'm not sure what to do.</p>

<p>I found a way. You need to use StringIO from python and download_fileobj() from boto3.</p>

<pre><code>import boto3
import StringIO
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter

output = StringIO.StringIO()
latest_file_object = s3_client.Object('bucket_name','latest_file')
latest_file_object.download_fileobj(output)

reader = DataFileReader(output, DatumReader())
for r in reader:
    print r
</code></pre>

python boto avro boto3