Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json,boto3
- def notebook2py(nb_bucket,nb_key,py_bucket,py_key):
- s3c = boto3.client('s3')
- obj = s3c.get_object(Bucket=nb_bucket, Key=nb_key)
- content = json.loads(obj['Body'].read())
- notebook_text = ['\n'+item['text'][8::] for item in content['paragraphs'] if 'enabled' in item['config'] and item['config']['enabled']==True and item['text'].startswith('%pyspark')]
- io_handle = StringIO('\n'.join(notebook_text))
- s3c.put_object(Bucket=py_bucket, Key=py_key, Body=io_handle.read())
Add Comment
Please, Sign In to add comment