1

From Sagemaker

log file is read like follows:

sess = boto3.Session(region_name)
s3client = sess.client("S3")
log_obj = s3client.get_object(Bucket=bucket_name, Key=log_file_path)
log_obj["Body"].read()

which looks like this:

b'hello world this is log file1 \n arguments passed to function are \n [a,b,c,d] \n and so on...'

It is in one large text, unlike logs I see from other SO questions...

If \n writes next string into new line it would be much more easy to read, is there a way to let python NOT ignore escape character?

Or if there is better way to parse log of text from S3, let me know.

5
  • Try log_obj["Body"].read().decode() Commented Mar 18, 2022 at 8:04
  • Still the same. Commented Mar 18, 2022 at 8:14
  • 1
    Have you tried it with a for loop: Python: read all text file lines in loop Commented Mar 18, 2022 at 8:30
  • How do you know it does not respect \n? In your code you are not using log_obj["Body"].read() at all. What do you do with it? Save to a file? Print onto a console? Commented Mar 18, 2022 at 8:55
  • @Marcin there is log_obj["Body"].read(), last line. I'm trying to read it in sagemaker since simply downloading it from s3 has broken letters when opened. Commented Mar 18, 2022 at 9:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.