{"id":1193,"date":"2021-05-15T14:39:13","date_gmt":"2021-05-15T14:39:13","guid":{"rendered":"http:\/\/blog.successionua.com\/?p=1193"},"modified":"2021-05-15T16:14:47","modified_gmt":"2021-05-15T16:14:47","slug":"python-%d0%ba%d0%b0%d0%ba-%d1%81%d0%ba%d0%be%d0%bd%d0%b2%d0%b5%d1%80%d1%82%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d1%82%d1%8c-%d1%84%d0%b0%d0%b9%d0%bb-csv-%d0%b2-xlsx","status":"publish","type":"post","link":"https:\/\/geckich.space\/?p=1193","title":{"rendered":"Python, \u043a\u0430\u043a \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b .csv \u0432 .xlsx"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u041d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 csv -&gt; xlsx \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 python 2.7. \u041d\u0430 2.6 \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c openpyxl \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>pip install openpyxl<\/strong>, \u0430 \u043d\u0430 3\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 io.open \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e open:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import io\n<code>from openpyxl import Workbook<\/code>\n# Convert to XLSX\ncsvfile = 'path_to_file.csv'\nxlsxfile = 'path_to_file.xlsx'\nworkbook = Workbook(xlsxfile)\nworksheet = workbook.add_worksheet()\nwith io.open(csvfile, 'rt', encoding='utf8') as f:\n    reader = csv.reader(f)\n    for r, row in enumerate(reader):\n        for c, col in enumerate(row):\n            worksheet.write(r, c, col)\nworkbook.close()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u0441\u044b\u043b\u043a\u0438:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>https:\/\/stackoverflow.com\/questions\/17684610\/python-convert-csv-to-xlsx<\/li><li>https:\/\/openpyxl.readthedocs.io\/en\/stable\/index.html<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 csv -&gt; xlsx \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 python 2.7. \u041d\u0430 2.6 \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c openpyxl \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip install openpyxl, \u0430 \u043d\u0430 3\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 io.open \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e open: import io from openpyxl import Workbook # Convert to XLSX csvfile = &#8216;path_to_file.csv&#8217; xlsxfile = &#8216;path_to_file.xlsx&#8217; workbook = Workbook(xlsxfile) worksheet = workbook.add_worksheet() &hellip; <a href=\"https:\/\/geckich.space\/?p=1193\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Python, \u043a\u0430\u043a \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b .csv \u0432 .xlsx<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,1],"tags":[159,48,116,165],"class_list":["post-1193","post","type-post","status-publish","format-standard","hentry","category-programming","category-uncategorized","tag-csv","tag-linux","tag-python","tag-xlsx"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/1193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1193"}],"version-history":[{"count":2,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/1193\/revisions"}],"predecessor-version":[{"id":1196,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/1193\/revisions\/1196"}],"wp:attachment":[{"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}