{"id":345324,"date":"2023-02-12T09:00:35","date_gmt":"2023-02-12T09:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=345324"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=345324","title":{"rendered":"<span>\u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u044b\u043d\u043a\u0430 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 (Yandex Data Lake + Power BI)<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u0430\u043a-\u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/658895\/\" rel=\"noopener noreferrer nofollow\">\u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u044b\u043d\u043a\u0430 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u0432 \u0442\u0440\u0438 \u043a\u043b\u0438\u043a\u0430<\/a>. \u0412 \u043d\u0435\u0439 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0438\u0441\u044c \u043a \u0441\u0430\u0439\u0442\u0443 HHru \u0438\u0437 Power BI, \u0437\u0430\u0431\u0438\u0440\u0430\u043b\u0438 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438 \u0438 \u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430. <\/p>\n<p>\u041d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043b\u0438\u0448\u0430\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u043d\u043e\u0441\u0442\u0438. \u0412 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u00ab\u0441\u043d\u0438\u043c\u043e\u043a\u00bb \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043d\u0435\u0433\u043e. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 <em>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c<\/em> \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0442\u0440\u0443\u0442\u0441\u044f. \u0411\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438? \u041c\u043d\u0435 \u0434\u0430. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u0438 \u0441\u0442\u043e\u0438\u0442 \u043f\u0430\u0440\u0443 \u0441\u043e\u0442\u0435\u043d \u0440\u0443\u0431\u043b\u0435\u0439 \u0432 \u0433\u043e\u0434. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u044b\u043b \u043f\u0440\u0438\u043d\u0446\u0438\u043f &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0434\u0435\u0448\u0435\u0432\u043e. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0441\u0442\u043e, \u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u00ab\u0441\u043d\u0438\u043c\u043a\u0438\u00bb \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438\u0447\u0435\u043c \u0441\u044b\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441\u0430\u0439\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON. \u041a \u044d\u0442\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438\u0437 Power BI. \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 1. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439, \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f CloudFunction \u043d\u0430 Python, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API \u0441\u0430\u0439\u0442\u0430 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u044b \u0432 ObjectStroge. \u0414\u0430\u043b\u0435\u0435 \u0441\u044b\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 parquet, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f Power BI. \u041f\u0440\u0438\u0447\u0435\u043c, \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 Power BI \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 (\u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438). <\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u042f\u043d\u0434\u0435\u043a\u0441 \u041e\u0431\u043b\u0430\u043a\u0430. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u0431\u043b\u0430\u043a\u0430 \u0437\u0430\u043f\u0430\u0434\u043d\u044b\u0445 \u0432\u0435\u043d\u0434\u043e\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Microsoft Azure, \u0431\u043e\u043b\u0435\u0435 \u0437\u0440\u0435\u043b\u044b\u0435 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0435. \u041d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u044d\u0442\u043e \u043e\u0442\u0440\u0435\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439. <\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ma\/ft\/ke\/maftke2cid-ku_94tpv_trysbiq.png\" alt=\"\u0440\u0438\u0441. 1 - \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\" title=\"\u0440\u0438\u0441. 1 - \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\" width=\"auto\" height=\"auto\" data-src=\"https:\/\/habrastorage.org\/webt\/ma\/ft\/ke\/maftke2cid-ku_94tpv_trysbiq.png\"\/><figcaption>\u0440\u0438\u0441. 1 &#8212; \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u0448\u0430\u0433\u0430\u043c.<br \/>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <a href=\"https:\/\/cloud.yandex.ru\" rel=\"noopener noreferrer nofollow\">\u042f\u043d\u0434\u0435\u043a\u0441 \u041e\u0431\u043b\u0430\u043a\u043e<\/a>, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f, \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>\u042f\u043d\u0434\u0435\u043a\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438  <\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 S3, \u043e\u043d\u043e \u0436\u0435 Data Lake, \u043e\u043d\u043e \u0436\u0435 Yandex Object Stroge<\/p>\n<\/li>\n<\/ul>\n<h2>Yandex Object Stroge<\/h2>\n<p>\u0412 Yandex Object Storage \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u0434\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 Object Storage \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c bucket. \u0412 bucket \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439, \u00a0\u044f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c. \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u044e\u0447 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u043a\u0435\u0442\u0443. \u0414\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u043f\u043e <a href=\"https:\/\/cloud.yandex.ru\/docs\/iam\/operations\/sa\/create-access-key\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/a> \u043e\u0442 \u044f\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<h2>Yandex Cloud Functions<\/h2>\n<p>\u042d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043d\u043e \u0432\u044b \u0434\u0435\u0440\u0436\u0438\u0442\u0435\u0441\u044c:-). \u0412 Cloud Functions \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043e \u0441\u0440\u0435\u0434\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 Python. \u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u043b \u043d\u0438\u0436\u0435. \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 300 \u0441\u0435\u043a\u0443\u043d\u0434. \u0418 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u043a \u043d\u0438\u043c, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 30 \u043c\u0438\u043d\u0443\u0442. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0442\u0430\u043a, \u0440\u0438\u0441\u0443\u043d\u043e\u043a 2 : <\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ox\/eo\/8f\/oxeo8f6ayozwnla2kgk8ns-plls.png\" alt=\"\u0440\u0438\u0441\u0443\u043d\u043e\u043a 2 - \u0422\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439\" title=\"\u0440\u0438\u0441\u0443\u043d\u043e\u043a 2 - \u0422\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439\" width=\"auto\" height=\"auto\" data-src=\"https:\/\/habrastorage.org\/webt\/ox\/eo\/8f\/oxeo8f6ayozwnla2kgk8ns-plls.png\"\/><figcaption>\u0440\u0438\u0441\u0443\u043d\u043e\u043a 2 &#8212; \u0422\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/figcaption><\/figure>\n<p>\u0412 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e. \u041f\u0435\u0440\u0432\u044b\u0439 requirements.txt \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 Python. \u0418 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c Python. \u0412 \u043a\u043e\u0434\u0435 \u043c\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0430\u0448\u0438, \u043e\u043d\u0438 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b, \u043d\u0430\u0439\u0434\u0435\u0442\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 1<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def handler(event, context):     import requests     import datetime     import boto3     import json     import pandas as pd     import csv     import io     from io import StringIO      def create_con():         os = boto3.client('s3',             aws_access_key_id = '\u0412\u0410\u0428 \u041a\u041b\u042e\u0427',             aws_secret_access_key = '\u0412\u0410\u0428 \u0421\u0415\u041a\u0420\u0415\u0422\u041d\u042b\u0419 \u041a\u041b\u042e\u0427',             region_name = 'central1',             endpoint_url = 'https:\/\/storage.yandexcloud.net'             )         return os     def get_maxpage(API):         adress = API         todos = requests.get(adress)         stat = todos.status_code         tbody  = json.loads(todos.text)         maxpage = tbody[\"pages\"]         return maxpage      def getAPI(text, API, page):         adress = API + '&amp;page=' + page         todos = requests.get(adress)         stat = todos.status_code         todos.encoding = 'utf-8'         todos.text         tbody = todos.json()         t2body = json.dumps(tbody, ensure_ascii=False)         df = pd.DataFrame(columns=['id', 'text', 'page'])         for item in tbody[\"items\"]:             df = df.append({'id': item['id'], 'text': text, 'page': page}, ignore_index=True)         return {             'statusCode': 200,             'body': df,         }          def get_list_req(os):         obj = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key='\u041f\u0423\u0422\u042c \u041a \u0424\u0410\u0419\u041b\u0423 requests.csv')         body = obj['Body'].read()         df = pd.read_csv(io.BytesIO(body))         return df      os = create_con() #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435      list_req = get_list_req(os) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432     df = pd.DataFrame(columns=['id', 'text', 'page'])     for index, row in list_req.iterrows(): #\u0426\u0438\u043a\u043b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c, \u0433\u0435\u043d\u0435\u0440\u044e \u0444\u0430\u0439\u043b\u044b json         maxpage = get_maxpage(row['API']) #\u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043a\u043e\u043b-\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446         int(maxpage)         for i in range(0, maxpage):             req = getAPI(row['text'], row['API'], str(i))             df = df.append(req[\"body\"], ignore_index=True)     csv_buffer = StringIO()     df.to_csv(csv_buffer)     os.put_object(Bucket=\"\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422\", Body=csv_buffer.getvalue(), Key=\"Lakehouse\/Config\/\" + \"All_id_for_parse.csv\", StorageClass='STANDARD') <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def handler(event, context):     import requests     import datetime     import boto3     import json     import pandas as pd     import csv     import io     from io import StringIO      def create_con():         os = boto3.client('s3',             aws_access_key_id = '\u0412\u0410\u0428 \u041a\u041b\u042e\u0427',             aws_secret_access_key = '\u0412\u0410\u0428 \u0421\u0415\u041a\u0420\u0415\u0422\u041d\u042b\u0419 \u041a\u041b\u042e\u0427',             region_name = 'central1',             endpoint_url = 'https:\/\/storage.yandexcloud.net'             )         return os      def getAPI(text, id):         adress = 'https:\/\/api.hh.ru\/' + 'vacancies\/' + str(id)         todos = requests.get(adress)         stat = todos.status_code         todos.encoding = 'utf-8'         todos.text         tbody = todos.json()         t2body = json.dumps(tbody, ensure_ascii=False)         now = datetime.date.today()         file_key = 'Lakehouse\/Data\/raw\/' + now.strftime('%Y-%m-%d') + '\/' + text + '\/' + str(id) + '.json'         os.put_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422', Body=t2body, Key=file_key, StorageClass='STANDARD')          def get_list_req(os):         obj = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key='Lakehouse\/Config\/All_id_for_parse.csv')         body = obj['Body'].read()         df = pd.read_csv(io.BytesIO(body))         return df      os = create_con() #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435      list_req = get_list_req(os) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432     df = pd.DataFrame(columns=['id', 'text', 'page'])     for index, row in list_req.iterrows(): #\u0426\u0438\u043a\u043b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c, \u0433\u0435\u043d\u0435\u0440\u044e \u0444\u0430\u0439\u043b\u044b json         req = getAPI(row['text'], row['id'])<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 3<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def handler(event, context):     import pandas as pd     import requests     from datetime import datetime, date     import boto3     import json     import io     from io import StringIO     from io import BytesIO     import pyarrow, fastparquet     import urllib3     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)     mydate = str(date.today())     data=[]     columns=['id', 'name', 'salary', 'experience', 'schedule', 'employment', 'key_skills', 'employerName', 'accept_temporary',\\                                      'publishedAt', 'arhived', 'areaId', 'areaName', 'alternate_url', 'working_days', 'working_time_intervals', 'DateLoad', 'fileKey']     df = pd.DataFrame(data, columns=columns)                            df3 = df     df_mart = df     def create_con():         os = boto3.client('s3',             aws_access_key_id = '\u0412\u0410\u0428 \u041a\u041b\u042e\u0427',             aws_secret_access_key = '\u0412\u0410\u0428 \u0421\u0415\u041a\u0420\u0415\u0422\u041d\u042b\u0419 \u041a\u041b\u042e\u0427',             region_name = 'central1',             endpoint_url = 'https:\/\/storage.yandexcloud.net',             verify=False             )         return os          def get_all_s3_keys(os, bucket, prefix):         \"\"\"Get a list of all keys in an S3 bucket.\"\"\"         df = pd.DataFrame(columns=['file_key'])         kwargs = {'Bucket': bucket, 'Prefix': prefix}         while True:             resp = os.list_objects_v2(**kwargs)             for obj in resp['Contents']:                 df = pd.concat([pd.DataFrame([[obj['Key']]], columns=df.columns), df], ignore_index=True)             try:              kwargs['ContinuationToken'] = resp['NextContinuationToken']             except KeyError:                 break            return df       def go_file(os, Key):         obj = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key=Key) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0444\u0430\u0439\u043b \u0434\u0436\u043e\u043d         todos = json.loads(obj['Body'].read())         if todos[\"experience\"] is not None:             experience = todos[\"experience\"][\"id\"]         if todos[\"schedule\"] is not None:             schedule = todos[\"schedule\"][\"id\"]         if todos[\"employment\"] is not None:             employment = todos[\"employment\"][\"id\"]         try:             employerName = todos[\"employer\"][\"name\"]         except:             employerName = None         try:             areaId = todos[\"area\"][\"id\"]             areaName = todos[\"area\"][\"name\"]         except:             areaId = None             areaName = None         row = [todos[\"id\"], todos[\"name\"], todos[\"salary\"], experience, schedule, employment, todos[\"key_skills\"], employerName, todos[\"accept_temporary\"],\\                 todos[\"published_at\"],\\                todos[\"archived\"], areaId, areaName, todos[\"alternate_url\"], todos[\"working_days\"], todos[\"working_time_intervals\"], datetime.now(), Key]         return pd.DataFrame([row], columns=columns)          os = create_con() #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     df_list_file_key = get_all_s3_keys(os, '\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422', 'Lakehouse\/Data\/raw\/' + mydate) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0444\u0430\u0439\u043b\u043e\u0432     for ind in df_list_file_key.index:             df_res = go_file(os, df_list_file_key['file_key'][ind])             df3 = pd.concat([df3, df_res])     out_buffer = BytesIO()     try:         obj_mart = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key='Lakehouse\/Data\/proccessed\/datamart') #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0444\u0430\u0439\u043b parquet         df_mart =  pd.read_parquet(io.BytesIO(obj_mart['Body'].read()))     except:         y = 1     df_datamart = pd.concat([df_mart,df3]).drop_duplicates(['fileKey'],keep='last').sort_values('fileKey')     df_datamart.astype(str).to_parquet(out_buffer, index=False)     os.put_object(Bucket=\"\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422\", Body=out_buffer.getvalue(), Key='Lakehouse\/Data\/proccessed\/datamart', StorageClass='STANDARD')     return 'OK'<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u0430 requirements.txt<\/summary>\n<div class=\"spoiler__content\">\n<p>boto3<br \/>datetime<br \/>pandas<br \/>fsspec<br \/>requests<br \/>pyarrow<br \/>fastparquet<br \/>urllib3<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u0430 requests.csv<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>\"number\",\"text\",\"API\" \"1\",\"Azure\",\"https:\/\/api.hh.ru\/vacancies?text=Azure&amp;search_field=name\" \"2\",\"data scientist\",\"https:\/\/api.hh.ru\/vacancies?text=data scientist&amp;search_field=name\" \"3\",\"data engineer\",\"https:\/\/api.hh.ru\/vacancies?text=data engineer&amp;search_field=name\"<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u0424\u0430\u0439\u043b  <em>requests.csv<\/em><strong> <\/strong>\u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b  \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422 &#8212; Lakehouse &#8212; Config &#8212; requests.csv.<strong> <\/strong><\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 1 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0437 \u0431\u0430\u043a\u0435\u0442\u0430 \u0444\u0430\u0439\u043b requests.csv \u0441 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u044f\u043c\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b hhru, \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 id \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b All_id_for_parse.csv. \u041f\u0438\u0442\u043e\u043d\u0438\u0441\u0442\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u043a\u0443\u0439\u0442\u0435 \u043a\u043e\u0434:). \u041f\u043e\u0441\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f 2 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 hhru \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 id \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438. \u0414\u0432\u0430 \u0448\u0430\u0433\u0430 \u043d\u0443\u0436\u043d\u044b \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043f\u043e id \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0439 json, \u0447\u0435\u043c \u043f\u0440\u0438 \u043e\u0431\u0449\u0435\u0439 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0432\u044b\u0434\u0430\u0447\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 1. \u0424\u0443\u043d\u043a\u0446\u0438\u044f 3 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u0438\u0442\u0440\u0438\u043d\u0443 &#8212;  \u0444\u0430\u0439\u043b <em>datamart.parquet<\/em> c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432 json. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d \u00a0\u0434\u043b\u044f Power BI. <\/p>\n<blockquote>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0432\u0435, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 <a href=\"https:\/\/cloud.yandex.ru\/services\/query\" rel=\"noopener noreferrer nofollow\">Yandex query<\/a>. \u041d\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 json, \u043a\u043e\u0438\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0448\u0438 json. <\/p>\n<\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Power BI. <\/p>\n<h2>Power BI<\/h2>\n<p>\u0414\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u0438\u0442\u0440\u0438\u043d\u044b \u0432 Power BI \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a <em>\u0424\u0430\u0439\u043b &#8212; Parquet<\/em>. \u0412 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u0430\u0439\u043b, \u043a\u0430\u043a<br \/> &#171;http:\/\/\u0412\u0410\u0428\u0411\u0410\u041a\u0415\u0422.storage.yandexcloud.net\/Lakehouse\/Data\/proccessed\/datamart&#187;. <br \/>\u0412 \u0444\u0430\u0439\u043b\u0435 <em>datamart.parquet <\/em>\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u043a\u0430\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u0441\u043f\u0438\u0441\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 Power BI. \u0412 Power qwery \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0432 \u0434\u0432\u0430 \u043a\u043b\u0438\u043a\u0430. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0432\u0441\u0435. \u041c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0430\u0448\u0431\u043e\u0440\u0434. \u041c\u043e\u0439 \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u043e\u0442\u043a\u0440\u044b\u0442 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e <a href=\"https:\/\/app.powerbi.com\/view?r=eyJrIjoiYmQ5MzM5ODgtNTI1MC00ZWFlLWJlYzUtNDRhMmY5NjNhNDRhIiwidCI6IjVhM2NhYWYxLWE5NjktNDNkMS04ZmRhLWZjYjE1OWJlYTVkNCIsImMiOjh9\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 &#8212; Data Lake + BI. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0446\u0435\u043b\u044f\u0445 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0439. \u0421\u0442\u043e\u0438\u0442 \u0434\u0435\u0448\u0435\u0432\u043e. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u043e \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0446\u0438\u0444\u0440\u044b \u0442\u0430\u043a\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430 15 \u0434\u043d\u0435\u0439 \u043f\u0440\u0438\u0448\u043b\u043e 700Mb \u0441\u044b\u0440\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0444\u043e\u0440\u043c\u0430\u0442 json<\/p>\n<\/li>\n<li>\n<p> 700 Mb \u0441\u044b\u0440\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 = 0,85 \u041cb \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0442\u0440\u0438\u043d\u0435, \u0444\u043e\u0440\u043c\u0430\u0442 parquet<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0433\u043e\u0434 \u0432\u0438\u0442\u0440\u0438\u043d\u0430 \u043f\u0440\u0438\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u043d\u0430 21 \u041cb, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0436\u0438\u0442\u044c \u043b\u0435\u0442 10<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043f\u043e 84 \u043a\u043e\u043f\u0435\u0439\u043a\u0438, \u0432 \u0433\u043e\u0434 295 \u0440.<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044f \u043e\u0442\u0447\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/716374\/\"> https:\/\/habr.com\/ru\/post\/716374\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u0430\u043a-\u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/658895\/\" rel=\"noopener noreferrer nofollow\">\u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u044b\u043d\u043a\u0430 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u0432 \u0442\u0440\u0438 \u043a\u043b\u0438\u043a\u0430<\/a>. \u0412 \u043d\u0435\u0439 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0438\u0441\u044c \u043a \u0441\u0430\u0439\u0442\u0443 HHru \u0438\u0437 Power BI, \u0437\u0430\u0431\u0438\u0440\u0430\u043b\u0438 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438 \u0438 \u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430. <\/p>\n<p>\u041d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043b\u0438\u0448\u0430\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u043d\u043e\u0441\u0442\u0438. \u0412 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u00ab\u0441\u043d\u0438\u043c\u043e\u043a\u00bb \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043d\u0435\u0433\u043e. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 <em>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c<\/em> \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0442\u0440\u0443\u0442\u0441\u044f. \u0411\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438? \u041c\u043d\u0435 \u0434\u0430. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u0438 \u0441\u0442\u043e\u0438\u0442 \u043f\u0430\u0440\u0443 \u0441\u043e\u0442\u0435\u043d \u0440\u0443\u0431\u043b\u0435\u0439 \u0432 \u0433\u043e\u0434. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u044b\u043b \u043f\u0440\u0438\u043d\u0446\u0438\u043f &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0434\u0435\u0448\u0435\u0432\u043e. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0441\u0442\u043e, \u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u00ab\u0441\u043d\u0438\u043c\u043a\u0438\u00bb \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438\u0447\u0435\u043c \u0441\u044b\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441\u0430\u0439\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON. \u041a \u044d\u0442\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438\u0437 Power BI. \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 1. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439, \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f CloudFunction \u043d\u0430 Python, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API \u0441\u0430\u0439\u0442\u0430 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u044b \u0432 ObjectStroge. \u0414\u0430\u043b\u0435\u0435 \u0441\u044b\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 parquet, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f Power BI. \u041f\u0440\u0438\u0447\u0435\u043c, \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 Power BI \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 (\u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438). <\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u042f\u043d\u0434\u0435\u043a\u0441 \u041e\u0431\u043b\u0430\u043a\u0430. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u0431\u043b\u0430\u043a\u0430 \u0437\u0430\u043f\u0430\u0434\u043d\u044b\u0445 \u0432\u0435\u043d\u0434\u043e\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Microsoft Azure, \u0431\u043e\u043b\u0435\u0435 \u0437\u0440\u0435\u043b\u044b\u0435 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0435. \u041d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u044d\u0442\u043e \u043e\u0442\u0440\u0435\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439. <\/p>\n<figure class=\"\"><figcaption>\u0440\u0438\u0441. 1 &#8212; \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u0448\u0430\u0433\u0430\u043c.<br \/>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <a href=\"https:\/\/cloud.yandex.ru\" rel=\"noopener noreferrer nofollow\">\u042f\u043d\u0434\u0435\u043a\u0441 \u041e\u0431\u043b\u0430\u043a\u043e<\/a>, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f, \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>\u042f\u043d\u0434\u0435\u043a\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438  <\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 S3, \u043e\u043d\u043e \u0436\u0435 Data Lake, \u043e\u043d\u043e \u0436\u0435 Yandex Object Stroge<\/p>\n<\/li>\n<\/ul>\n<h2>Yandex Object Stroge<\/h2>\n<p>\u0412 Yandex Object Storage \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u0434\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 Object Storage \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c bucket. \u0412 bucket \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439, \u00a0\u044f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c. \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u044e\u0447 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u043a\u0435\u0442\u0443. \u0414\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u043f\u043e <a href=\"https:\/\/cloud.yandex.ru\/docs\/iam\/operations\/sa\/create-access-key\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/a> \u043e\u0442 \u044f\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<h2>Yandex Cloud Functions<\/h2>\n<p>\u042d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043d\u043e \u0432\u044b \u0434\u0435\u0440\u0436\u0438\u0442\u0435\u0441\u044c:-). \u0412 Cloud Functions \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043e \u0441\u0440\u0435\u0434\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 Python. \u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u043b \u043d\u0438\u0436\u0435. \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 300 \u0441\u0435\u043a\u0443\u043d\u0434. \u0418 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u043a \u043d\u0438\u043c, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 30 \u043c\u0438\u043d\u0443\u0442. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0442\u0430\u043a, \u0440\u0438\u0441\u0443\u043d\u043e\u043a 2 : <\/p>\n<figure class=\"\"><figcaption>\u0440\u0438\u0441\u0443\u043d\u043e\u043a 2 &#8212; \u0422\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/figcaption><\/figure>\n<p>\u0412 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e. \u041f\u0435\u0440\u0432\u044b\u0439 requirements.txt \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 Python. \u0418 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c Python. \u0412 \u043a\u043e\u0434\u0435 \u043c\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0430\u0448\u0438, \u043e\u043d\u0438 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b, \u043d\u0430\u0439\u0434\u0435\u0442\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 1<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def handler(event, context):     import requests     import datetime     import boto3     import json     import pandas as pd     import csv     import io     from io import StringIO      def create_con():         os = boto3.client('s3',             aws_access_key_id = '\u0412\u0410\u0428 \u041a\u041b\u042e\u0427',             aws_secret_access_key = '\u0412\u0410\u0428 \u0421\u0415\u041a\u0420\u0415\u0422\u041d\u042b\u0419 \u041a\u041b\u042e\u0427',             region_name = 'central1',             endpoint_url = 'https:\/\/storage.yandexcloud.net'             )         return os     def get_maxpage(API):         adress = API         todos = requests.get(adress)         stat = todos.status_code         tbody  = json.loads(todos.text)         maxpage = tbody[\"pages\"]         return maxpage      def getAPI(text, API, page):         adress = API + '&amp;page=' + page         todos = requests.get(adress)         stat = todos.status_code         todos.encoding = 'utf-8'         todos.text         tbody = todos.json()         t2body = json.dumps(tbody, ensure_ascii=False)         df = pd.DataFrame(columns=['id', 'text', 'page'])         for item in tbody[\"items\"]:             df = df.append({'id': item['id'], 'text': text, 'page': page}, ignore_index=True)         return {             'statusCode': 200,             'body': df,         }          def get_list_req(os):         obj = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key='\u041f\u0423\u0422\u042c \u041a \u0424\u0410\u0419\u041b\u0423 requests.csv')         body = obj['Body'].read()         df = pd.read_csv(io.BytesIO(body))         return df      os = create_con() #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435      list_req = get_list_req(os) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432     df = pd.DataFrame(columns=['id', 'text', 'page'])     for index, row in list_req.iterrows(): #\u0426\u0438\u043a\u043b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c, \u0433\u0435\u043d\u0435\u0440\u044e \u0444\u0430\u0439\u043b\u044b json         maxpage = get_maxpage(row['API']) #\u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043a\u043e\u043b-\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446         int(maxpage)         for i in range(0, maxpage):             req = getAPI(row['text'], row['API'], str(i))             df = df.append(req[\"body\"], ignore_index=True)     csv_buffer = StringIO()     df.to_csv(csv_buffer)     os.put_object(Bucket=\"\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422\", Body=csv_buffer.getvalue(), Key=\"Lakehouse\/Config\/\" + \"All_id_for_parse.csv\", StorageClass='STANDARD') <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def handler(event, context):     import requests     import datetime     import boto3     import json     import pandas as pd     import csv     import io     from io import StringIO      def create_con():         os = boto3.client('s3',             aws_access_key_id = '\u0412\u0410\u0428 \u041a\u041b\u042e\u0427',             aws_secret_access_key = '\u0412\u0410\u0428 \u0421\u0415\u041a\u0420\u0415\u0422\u041d\u042b\u0419 \u041a\u041b\u042e\u0427',             region_name = 'central1',             endpoint_url = 'https:\/\/storage.yandexcloud.net'             )         return os      def getAPI(text, id):         adress = 'https:\/\/api.hh.ru\/' + 'vacancies\/' + str(id)         todos = requests.get(adress)         stat = todos.status_code         todos.encoding = 'utf-8'         todos.text         tbody = todos.json()         t2body = json.dumps(tbody, ensure_ascii=False)         now = datetime.date.today()         file_key = 'Lakehouse\/Data\/raw\/' + now.strftime('%Y-%m-%d') + '\/' + text + '\/' + str(id) + '.json'         os.put_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422', Body=t2body, Key=file_key, StorageClass='STANDARD')          def get_list_req(os):         obj = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key='Lakehouse\/Config\/All_id_for_parse.csv')         body = obj['Body'].read()         df = pd.read_csv(io.BytesIO(body))         return df      os = create_con() #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435      list_req = get_list_req(os) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432     df = pd.DataFrame(columns=['id', 'text', 'page'])     for index, row in list_req.iterrows(): #\u0426\u0438\u043a\u043b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c, \u0433\u0435\u043d\u0435\u0440\u044e \u0444\u0430\u0439\u043b\u044b json         req = getAPI(row['text'], row['id'])<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f 3<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def handler(event, context):     import pandas as pd     import requests     from datetime import datetime, date     import boto3     import json     import io     from io import StringIO     from io import BytesIO     import pyarrow, fastparquet     import urllib3     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)     mydate = str(date.today())     data=[]     columns=['id', 'name', 'salary', 'experience', 'schedule', 'employment', 'key_skills', 'employerName', 'accept_temporary',\\                                      'publishedAt', 'arhived', 'areaId', 'areaName', 'alternate_url', 'working_days', 'working_time_intervals', 'DateLoad', 'fileKey']     df = pd.DataFrame(data, columns=columns)                            df3 = df     df_mart = df     def create_con():         os = boto3.client('s3',             aws_access_key_id = '\u0412\u0410\u0428 \u041a\u041b\u042e\u0427',             aws_secret_access_key = '\u0412\u0410\u0428 \u0421\u0415\u041a\u0420\u0415\u0422\u041d\u042b\u0419 \u041a\u041b\u042e\u0427',             region_name = 'central1',             endpoint_url = 'https:\/\/storage.yandexcloud.net',             verify=False             )         return os          def get_all_s3_keys(os, bucket, prefix):         \"\"\"Get a list of all keys in an S3 bucket.\"\"\"         df = pd.DataFrame(columns=['file_key'])         kwargs = {'Bucket': bucket, 'Prefix': prefix}         while True:             resp = os.list_objects_v2(**kwargs)             for obj in resp['Contents']:                 df = pd.concat([pd.DataFrame([[obj['Key']]], columns=df.columns), df], ignore_index=True)             try:              kwargs['ContinuationToken'] = resp['NextContinuationToken']             except KeyError:                 break            return df       def go_file(os, Key):         obj = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key=Key) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0444\u0430\u0439\u043b \u0434\u0436\u043e\u043d         todos = json.loads(obj['Body'].read())         if todos[\"experience\"] is not None:             experience = todos[\"experience\"][\"id\"]         if todos[\"schedule\"] is not None:             schedule = todos[\"schedule\"][\"id\"]         if todos[\"employment\"] is not None:             employment = todos[\"employment\"][\"id\"]         try:             employerName = todos[\"employer\"][\"name\"]         except:             employerName = None         try:             areaId = todos[\"area\"][\"id\"]             areaName = todos[\"area\"][\"name\"]         except:             areaId = None             areaName = None         row = [todos[\"id\"], todos[\"name\"], todos[\"salary\"], experience, schedule, employment, todos[\"key_skills\"], employerName, todos[\"accept_temporary\"],\\                 todos[\"published_at\"],\\                todos[\"archived\"], areaId, areaName, todos[\"alternate_url\"], todos[\"working_days\"], todos[\"working_time_intervals\"], datetime.now(), Key]         return pd.DataFrame([row], columns=columns)          os = create_con() #\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     df_list_file_key = get_all_s3_keys(os, '\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422', 'Lakehouse\/Data\/raw\/' + mydate) #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0444\u0430\u0439\u043b\u043e\u0432     for ind in df_list_file_key.index:             df_res = go_file(os, df_list_file_key['file_key'][ind])             df3 = pd.concat([df3, df_res])     out_buffer = BytesIO()     try:         obj_mart = os.get_object(Bucket='\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422',Key='Lakehouse\/Data\/proccessed\/datamart') #\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0444\u0430\u0439\u043b parquet         df_mart =  pd.read_parquet(io.BytesIO(obj_mart['Body'].read()))     except:         y = 1     df_datamart = pd.concat([df_mart,df3]).drop_duplicates(['fileKey'],keep='last').sort_values('fileKey')     df_datamart.astype(str).to_parquet(out_buffer, index=False)     os.put_object(Bucket=\"\u0412\u0410\u0428 \u0411\u0410\u041a\u0415\u0422\", Body=out_buffer.getvalue(), Key='Lakehouse\/Data\/proccessed\/datamart', StorageClass='STANDARD')     return 'OK'<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u0430 requirements.txt<\/summary>\n<div class=\"spoiler__content\">\n<p>boto3<br \/>datetime<br \/>pandas<br \/>fsspec<br \/>requests<br \/>pyarrow<br \/>fastparquet<br \/>urllib3<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441<\/summary>\n<\/details>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-345324","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/345324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345324"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/345324\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}