Reading the data written to s3 by Amazon Kinesis Firehose stream

后端 未结 9 2023
感情败类
感情败类 2021-02-18 15:17

I am writing record to Kinesis Firehose stream that is eventually written to a S3 file by Amazon Kinesis Firehose.

My record object looks like

ItemPurcha         


        
9条回答
  •  不思量自难忘°
    2021-02-18 15:38

    Use this simple Python code.

    input_str = '''{"personId":"p-111","itemId":"i-111"}{"personId":"p-222","itemId":"i-222"}{"personId":"p-333","itemId":"i-333"}'''
    
    data_str = "[{}]".format(input_str.replace("}{","},{"))
    data_json = json.loads(data_str)
    

    And then (if you want) convert to Pandas.

    import pandas as pd   
    df = pd.DataFrame().from_records(data_json)
    print(df)
    

    And this is result

    itemId personId
    0  i-111    p-111
    1  i-222    p-222
    2  i-333    p-333
    

提交回复
热议问题