{"id":334023,"date":"2022-06-03T15:00:50","date_gmt":"2022-06-03T15:00:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334023"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334023","title":{"rendered":"<span>Pandas vs dask vs sqlite \u043d\u0430 raspberry pi<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/di\/ph\/_n\/diph_nw49ll6du_qszobbvhtyoy.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/di\/ph\/_n\/diph_nw49ll6du_qszobbvhtyoy.jpeg\" data-blurred=\"true\"\/><\/div>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434\u043e\u0432 (barcode) \u043d\u0430 \u043e\u0434\u043d\u043e\u043f\u043b\u0430\u0442\u043d\u0438\u043a\u0435 raspberry pi. \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u2014 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (~700 \u041c\u0431), \u043d\u0430\u0439\u0442\u0438 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u00ab\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u00bb. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u043a \u0432 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432 \u0431\u0430\u0437\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043e\u0434, \u0442\u0430\u043a \u0438 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u0443 \u0431\u0430\u0437\u0443 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438. \u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 pandas, dask, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 sqlite. \u041a\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441\u044b \u2014 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0430\u043c\u0430 \u0431\u0430\u0437\u0430 \u043a\u043e\u0434\u043e\u0432 (barcodes) \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0430\u0441\u044c \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0430 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u2014 <a href=\"https:\/\/github.com\/papyrussolution\/UhttBarcodeReference\/releases\" rel=\"nofollow noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c.<\/a> \u0415\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u0446\u0435\u043b\u0430\u044f \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u0430\u044f \u0435\u0439 \u2014 <a href=\"https:\/\/habr.com\/ru\/post\/420585\/\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e: \u0431\u0430\u0437\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f csv \u0444\u0430\u0439\u043b ~774\u041c\u0431 \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u043e\u0441\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">\"\"\" * (ID) \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 Universe-HTT * (UPCEAN) \u0428\u0442\u0440\u0438\u0445\u043a\u043e\u0434 * (Name) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 * (CategoryID) \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 Universe-HTT * (CategoryName) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 * (BrandID) \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0440\u044d\u043d\u0434\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 Universe-HTT * (BrandName) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0440\u044d\u043d\u0434\u0430 \"\"\"<\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u043c\u0435\u044e\u0442 \u0441\u0442\u043e\u043b\u0431\u0446\u044b (UPCEAN) \u0428\u0442\u0440\u0438\u0445\u043a\u043e\u0434 \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434, (Name) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430, (CategoryName) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, (BrandName) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0440\u044d\u043d\u0434\u0430. <\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u0444\u0435:<\/p>\n<pre><code class=\"python\">\u0422\u043e\u0432\u0430\u0440:  \u041a\u043e\u0444\u0435 lavazza crema E gusto, \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043b\u043e\u0442\u044b\u0439 250\u0433, \u0432\u0430\u043a \u0443\u043f, 3876 \u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f:  \u041f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u043f\u0438\u0442\u0430\u043d\u0438\u044f (folder)\/\u0427\u0430\u0439 \u0438 \u043a\u043e\u0444\u0435\/\u041a\u043e\u0444\u0435 \u043c\u043e\u043b\u043e\u0442\u044b\u0439 \u0411\u0440\u044d\u043d\u0434:  Lavazza <\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0438 csv \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442.<\/p>\n<h3>Pandas.<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tn\/fq\/fo\/tnfqfo2vtskutmehml6xdjifzys.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tn\/fq\/fo\/tnfqfo2vtskutmehml6xdjifzys.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438 \u043c\u0430\u043b\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b (dataframes). \u0422\u0430\u043a \u043a\u0430\u043a \u0431\u0430\u0437\u0430 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434\u043e\u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f &lt;1\u0413\u0431, pandas \u0434\u043e\u043b\u0436\u0435\u043d \u0441 \u043d\u0435\u0439 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043d\u0430 raspberry pi 4b.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441sv \u0444\u0430\u0439\u043b\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c\u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0432 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c:<\/p>\n<pre><code class=\"python\">df = pd.read_csv('uhtt_barcode_ref_all.csv',                    warn_bad_lines=True,                                       dtype ={'ID':'object','UPCEAN':'int64','Name':'object','CategoryID':'category',                    'CategoryName':'category','BrandID':'category','BrandName':'category'},                     delimiter='\\t') <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, UPCEAN \u043a\u043e\u0434\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 int64, Name \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a object, CategoryName, BrandName, BrandID \u0432 category. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, ID \u0438 CategoryID \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 int, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043c \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0431\u0438\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tq\/3y\/q5\/tq3yq5xurs61enw8fgdh-wwd4ps.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tq\/3y\/q5\/tq3yq5xurs61enw8fgdh-wwd4ps.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u043b \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0411\u0435\u0437 \u043d\u0438\u0445 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">df = pd.read_csv('uhtt_barcode_ref_all.csv',                    warn_bad_lines=True,                      delimiter='\\t') <\/code><\/pre>\n<p>  \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/-p\/vh\/im\/-pvhimi5eyndnqz4xyamz_bovqw.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/-p\/vh\/im\/-pvhimi5eyndnqz4xyamz_bovqw.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0427\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430?<\/p>\n<p>  <b>\u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b (h:min:sec): 0:01:13<\/b><\/p>\n<p>  *\u0432\u0440\u0435\u043c\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u043f\u0440\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e dtype \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0442\u044b pandas \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430, \u0430 \u043d\u0435 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c.<\/p>\n<p>  \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0430\u043c \u043f\u043e\u0438\u0441\u043a? <\/p>\n<p>  \u041f\u043e\u0438\u0449\u0435\u043c \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">some_value = 4603726031011 a=df.loc[df['UPCEAN'] == some_value] print('\u0442\u043e\u0432\u0430\u0440: {} , \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f: {}, \u0431\u0440\u044d\u043d\u0434: {}'\\       .format(a.at[1,'Name'],a.at[1,'CategoryName'], a.at[1,'BrandName'])) <\/code><\/pre>\n<p>  \u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0431\u0430\u0437\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/6j\/hd\/bg\/6jhdbg6qdoolgzormt5a1zitfj4.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/6j\/hd\/bg\/6jhdbg6qdoolgzormt5a1zitfj4.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u044a\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0434\u043d\u043e\u043f\u043b\u0430\u0442\u043d\u0438\u043a\u0430.<\/p>\n<p>  \u0427\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0438? <\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b: \u0438\u0445 \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0435.<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, pandas \u0442\u0430\u043a \u043d\u0435 \u0443\u043c\u0435\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"python\">header = ['UPCEAN','Name','CategoryName','BrandName'] df.to_csv('out.csv', columns = header, index=False,header=False, na_rep = 'N\/A', sep = '\\t', compression='gzip') <\/code><\/pre>\n<p>  *\u0437\u0430\u043e\u0434\u043d\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u0430\u0440\u0445\u0438\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 93\u041c\u0431 (\u0432\u043c\u0435\u0441\u0442\u043e 733\u041c\u0431).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0434\u0430\u043b\u0438 \u043b\u0438 \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430:<\/p>\n<pre><code class=\"python\">df = pd.read_csv('out.csv', compression='gzip',                  dtype ={'UPCEAN':'int64','Name':'object','CategoryName':'category','BrandName':'category'},                    warn_bad_lines=True,                      delimiter='\\t') <\/code><\/pre>\n<p>  \u0418\u0442\u043e\u0433: <\/p>\n<p>  <b>\u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b (h:min:sec:msec): 0:01:00.588706<\/b><\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0438\u0433\u0440\u0430\u0442\u044c 30 \u0441\u0435\u043a, \u0447\u0442\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e. <\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0440\u0435\u043c\u044f \u0432 1 \u043c\u0438\u043d \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0431\u0430\u0437\u0435, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0438\u0441\u043a, \u0430 \u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e.<\/p>\n<h3>Dask<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/7m\/u6\/pm\/7mu6pmp0c73f63ksjocfom9ivns.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/7m\/u6\/pm\/7mu6pmp0c73f63ksjocfom9ivns.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 dask. \u0427\u0442\u043e\u0431\u044b \u0441 \u043d\u0438\u043c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c. <\/p>\n<p>  \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u0435\u0441\u0442\u044c, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441.<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c dask \u043d\u0430 raspberry pi, \u0430 \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043d\u0430 armv7l \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 pip install dask \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>  Dask \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pyarrow, \u0430 \u043e\u043d\u0430, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0438 \u0447\u0435\u0440\u0435\u0437 pip, \u043d\u0438 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441 \u0441\u0430\u0439\u0442\u0430 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u043e\u0431\u0440\u0430\u0442\u044c pyarrow \u0432\u0441\u0435-\u0442\u0430\u043a\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043d\u0430 \u044d\u0442\u043e \u0443\u0439\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. <\/p>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u044d\u0442\u0438\u043c \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043d\u0438\u0436\u0435, \u0430 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043b\u0435\u0441\u043e(wheel).<\/p>\n<p>  <b>Dask \u0432 \u0434\u0435\u043b\u0435.<\/b><\/p>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u0440\u0435\u043c\u044f. <\/p>\n<p>  \u0417\u0430\u043e\u0434\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<pre><code class=\"python\">import dask.dataframe as dd import numpy as np from datetime import datetime  dtypes = { 'ID':'object',     'UPCEAN':'int64', 'Name':'object', 'CategoryID': 'object', 'CategoryName':'category', 'BrandID':'object', 'BrandName':'category'}  df = dd.read_csv('uhtt_barcode_ref_all.csv', dtype=dtypes, sep='\\t', \\                  comment='#', error_bad_lines=False,lineterminator='\\n') print('\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 (h:min:sec): '+str(datetime.now()- start)) <\/code><\/pre>\n<p>  <b>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 (h:min:sec): 0:00:00.059191<\/b><br \/>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e. \u041f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044c \u043d\u0430\u0439\u0434\u0435\u043d? <\/p>\n<p>  \u041d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u044b\u0432\u043e\u0434\u0430\u043c\u0438, \u043f\u043e\u0438\u0449\u0435\u043c \u043f\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">good = 4820024700016 a=df.loc[df['UPCEAN'] == good].compute() <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0434\u043d\u043e\u0436\u043a\u0443 \u043e\u0442 dask:<br \/>  <b>\u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443 (h:min:sec:msec): 0:00:42.424091<\/b><\/p>\n<p>  42 \u0441\u0435\u043a. \u041e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e. <\/p>\n<p>  \u041e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 dask. <\/p>\n<p>  \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 dask \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c lazy \u0440\u0435\u0436\u0438\u043c\u0435, \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u043f\u043e\u0438\u0441\u043a, \u0430 \u043b\u0438\u0448\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438. \u0421\u0430\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f compute().<\/p>\n<h3>\u041a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c dask?<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a dask, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 pandas \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430, \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430\u0434 \u0441\u0430\u043c\u0438\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c.<\/p>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 pandas, dask \u0443\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a parquet, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e, \u043d\u0435 \u0447\u0438\u0442\u0430\u044f \u0432\u0435\u0441\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0430\u0437\u0443 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 parquet \u0438 \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c:<\/p>\n<pre><code class=\"python\">df.to_parquet(\"data\/parquet\", engine=\"pyarrow\", compression='snappy') <\/code><\/pre>\n<p>  *\u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0441\u0436\u0430\u043b\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0431\u0430\u0437\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 204\u041c\u0431(\u0431\u044b\u043b\u043e 733\u041c\u0431) \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/oo\/kp\/om\/ookpomkqaxbfnqryxd3hgj_4qcm.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/oo\/kp\/om\/ookpomkqaxbfnqryxd3hgj_4qcm.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u043e\u0438\u0441\u043a \u0438 \u0437\u0430\u043c\u0435\u0440\u0438\u043c \u0432\u0440\u0435\u043c\u044f:<\/p>\n<pre><code class=\"python\">start = datetime.now() df = dd.read_parquet(\"parquet\", engine=\"pyarrow\", columns=[\"UPCEAN\", \"Name\",\"CategoryName\",\"BrandName\"])  print('\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 (h:min:sec): '+str(datetime.now()- start)[:-7]) good = 4820024700016 a=df.loc[df['UPCEAN'] == good].compute() a=a.to_string(index=False,header=False).split('  ')  print('\u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443 (h:min:sec): '+str(datetime.now()- start)[:-7]) <\/code><\/pre>\n<p>  \u0418\u0442\u043e\u0433:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/yc\/pp\/rg\/ycpprgctqvunedx1cms6vkia1q4.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/yc\/pp\/rg\/ycpprgctqvunedx1cms6vkia1q4.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  16 \u0441\u0435\u043a \u0432\u043c\u0435\u0441\u0442\u043e 44 \u0441\u0435\u043a. <\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, dask \u00ab\u0441 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f\u043c\u0438\u00bb \u0432\u044b\u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 16 \u0441\u0435\u043a. <\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043b\u0443\u0447\u0448\u0435? \u0421\u043b\u043e\u0432\u043e \u0437\u0430 sql. <\/p>\n<h3>Sqlite<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/jr\/x0\/7j\/jrx07jr1l-bwm-3odkppenzfmhe.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/jr\/x0\/7j\/jrx07jr1l-bwm-3odkppenzfmhe.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439 sqllite, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u0441 sqlite3, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <br \/>  csv \u0432 db. <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">import csv, sqlite3,sys #csv.field_size_limit(sys.maxsize)  \"\"\" * (ID) \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u043e\u0432\u0430\u0440\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 Universe-HTT * (UPCEAN) \u0428\u0442\u0440\u0438\u0445\u043a\u043e\u0434 * (Name) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u0432\u0430\u0440\u0430 * (CategoryID) \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 Universe-HTT * (CategoryName) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 * (BrandID) \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0440\u044d\u043d\u0434\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 Universe-HTT * (BrandName) \u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0440\u044d\u043d\u0434\u0430 \"\"\"  con = sqlite3.connect('my_big.db') cur = con.cursor() cur.execute(\"CREATE TABLE t (ID,UPCEAN,Name,CategoryID,CategoryName,BrandID,BrandName);\") # IDUPCEANNameCategoryIDCategoryNameBrandIDBrandName - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432  with open('uhtt_barcode_ref_all.csv','r', encoding='utf-8') as fin:     # csv.DictReader \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0434 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432     dr = csv.DictReader(fin, delimiter=\"\\t\",quoting=csv.QUOTE_NONE)     to_db = [(i['ID'], i['UPCEAN'], i['Name'],i['CategoryID'],\\               i['CategoryName'],i['BrandID'],i['BrandName']) for i in dr]  cur.executemany(\"INSERT INTO t (ID,UPCEAN,Name,CategoryID,CategoryName,BrandID,BrandName) VALUES (?, ?, ?, ?, ?, ?, ?);\", to_db) con.commit() con.close() <\/code><\/pre>\n<p>  \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u0430\u0437\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 835\u041c\u0431, \u0447\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c csv \u0444\u0430\u0439\u043b \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 (774\u041c\u0431).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u043c \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0431\u0430\u0437\u0435 \u0438\u0437 python \u0438 \u0437\u0430\u043c\u0435\u0440\u0438\u043c \u0432\u0440\u0435\u043c\u044f:<\/p>\n<pre><code class=\"python\">import sqlite3 from datetime import datetime start = datetime.now()  def read_sqlite_table(id):     try:         sqlite_connection = sqlite3.connect('my_big.db')         cursor = sqlite_connection.cursor()         print(\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a SQLite\")                 sql_select_query = \"\"\"select Name,CategoryName,BrandName from t where UPCEAN = ?\"\"\"         cursor.execute(sql_select_query, (id,))         for row in cursor:             print(row)         print(\"Name:\", row[0])         print(\"CategoryName:\", row[1])         print(\"BrandName\", row[2], end=\"\\n\\n\")          cursor.close()      except sqlite3.Error as error:         print(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 SQLite\", error)     finally:         if sqlite_connection:             sqlite_connection.close()             print(\"\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 SQLite \u0437\u0430\u043a\u0440\u044b\u0442\u043e\")  read_sqlite_table(str(5412058004308)) print('\u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443 (h:min:sec): '+str(datetime.now()- start)[:-7]) <\/code><\/pre>\n<p>  \u0418\u0442\u043e\u0433:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/-a\/mi\/b0\/-amib0teel1bgtcskpieyjdvwxk.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/-a\/mi\/b0\/-amib0teel1bgtcskpieyjdvwxk.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  3 \u0441\u0435\u043a. \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0434\u0435\u0441\u044c.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<ul>\n<li>\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434\u043e\u0432 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438;<\/li>\n<li>\u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e sqlite \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u044d\u0442\u043e \u043d\u0435 \u0443\u043c\u0430\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432;<\/li>\n<li>\u0432\u044b\u044f\u0441\u043d\u0435\u043d\u044b \u043d\u044e\u0430\u043d\u0441\u044b \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 pandas \u0438 dask \u043f\u0440\u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u0438 \u043d\u0430 raspberry pi \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438;<\/li>\n<li>\u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043d\u0435\u043e\u0446\u0435\u043d\u0438\u043c\u044b\u0439 \u043e\u043f\u044b\u0442 \u043c\u043d\u043e\u0433\u043e\u0447\u0430\u0441\u043e\u0432\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a pyarrow \u043d\u0430 arm.<\/li>\n<\/ul>\n<p>  <b>\u0421\u043a\u0430\u0447\u0430\u0442\u044c: <\/b><\/p>\n<ul>\n<li><a href=\"https:\/\/disk.yandex.ru\/d\/kiOuwbzV1XrK7w\" rel=\"nofollow noopener noreferrer\">pandas_read.py<\/a><\/li>\n<li><a href=\"https:\/\/disk.yandex.ru\/d\/bzwlVQEzIbwg9w\" rel=\"nofollow noopener noreferrer\">dask_read.py<\/a><\/li>\n<li><a href=\"https:\/\/disk.yandex.ru\/d\/3o3RuXG0Ak_b1w\" rel=\"nofollow noopener noreferrer\">convert_to_sqlite.py<\/a><\/li>\n<li><a href=\"https:\/\/disk.yandex.ru\/d\/ybAsT7HOYfSn_g\" rel=\"nofollow noopener noreferrer\">sqlite_read.py<\/a><\/li>\n<li><a href=\"https:\/\/disk.yandex.ru\/d\/0tI3kMf_xDwKPA\" rel=\"nofollow noopener noreferrer\">pyarrow_8.0.0_wheel<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0411\u043e\u043d\u0443\u0441. \u041a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c pyarrow \u043d\u0430 arm<\/h3>\n<p>  *under construction.<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/669416\/\"> https:\/\/habr.com\/ru\/post\/669416\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/di\/ph\/_n\/diph_nw49ll6du_qszobbvhtyoy.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/di\/ph\/_n\/diph_nw49ll6du_qszobbvhtyoy.jpeg\" data-blurred=\"true\"\/><\/div>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434\u043e\u0432 (barcode) \u043d\u0430 \u043e\u0434\u043d\u043e\u043f\u043b\u0430\u0442\u043d\u0438\u043a\u0435 raspberry pi. \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u2014 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (~700 \u041c\u0431), \u043d\u0430\u0439\u0442\u0438 \u0448\u0442\u0440\u0438\u0445\u043a\u043e\u0434 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u00ab\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u00bb. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u043a \u0432 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432 \u0431\u0430\u0437\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043e\u0434, \u0442\u0430\u043a \u0438 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u0443 \u0431\u0430\u0437\u0443 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438. \u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 pandas, dask, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 sqlite. \u041a\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441\u044b \u2014 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.  <\/p>\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-334023","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334023","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=334023"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334023\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}