{"id":592,"date":"2022-03-09T14:09:59","date_gmt":"2022-03-09T05:09:59","guid":{"rendered":"https:\/\/tippang.net\/?p=592"},"modified":"2022-03-10T19:01:59","modified_gmt":"2022-03-10T10:01:59","slug":"how-to-merge-a-few-excel-files-into-one-method-2","status":"publish","type":"post","link":"https:\/\/tippang.net\/?p=592","title":{"rendered":"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings)"},"content":{"rendered":"<p><em><strong>In a min, you can data manipulation as Excel &amp; Python Expert<\/strong><\/em><\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-584\" src=\"https:\/\/tippang.net\/wp-content\/uploads\/2022\/03\/python-Excel2021-02-28-\u110b\u1169\u1112\u116e-9.14-1.png\" alt=\"\" width=\"310\" height=\"129\" srcset=\"https:\/\/tippang.net\/wp-content\/uploads\/2022\/03\/python-Excel2021-02-28-\u110b\u1169\u1112\u116e-9.14-1.png 521w, https:\/\/tippang.net\/wp-content\/uploads\/2022\/03\/python-Excel2021-02-28-\u110b\u1169\u1112\u116e-9.14-1-300x125.png 300w\" sizes=\"(max-width: 310px) 100vw, 310px\" \/><\/p>\n<p><!--more--><\/p>\n<p>Step 1<\/p>\n<ul>\n<li>Installation of free python tools for MacBook\/Windows using pycharm program with anaconda<br \/>\n\u2192 a <a href=\"https:\/\/medium.com\/@GalarnykMichael\/setting-up-pycharm-with-anaconda-plus-installing-packages-windows-mac-db2b158bd8c\" target=\"_blank\" rel=\"noopener\">link<\/a> for installation guide<\/li>\n<\/ul>\n<p>Step 2<\/p>\n<ul>\n<li>Installation python plug-ins for Excel<br \/>\n\u2192 a <a href=\"https:\/\/docs.xlwings.org\/en\/stable\/installation.html\" target=\"_blank\" rel=\"noopener\">link<\/a> for installation guide<\/li>\n<li>Step by Step\n<ul>\n<li>Move to terminal in PyCharm<\/li>\n<li>Install plug-in using a comment : pip install package-name (xlwings-xxxx, pandas)\n<ul>\n<li>Example : pip install xlwings<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Step 3<\/p>\n<ul>\n<li>Writing a source Code (Sample) \u2192 a video link for installtion guide (tbd)<\/li>\n<li>Creation three excel files to merge as one file, then run python code to merge those\n<ul>\n<li>tmp1.xlsx, tmp2.xlsx, tmp3.xlsx \u2192 merged_one.xlsx<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong><em>\u2192 a sample code<\/em><\/strong><\/p>\n<p>import pandas as pd<br \/>\nfrom pathlib import Path<br \/>\nimport numpy as np<br \/>\nimport xlwings as xw<\/p>\n<p>input_folder = &#8216;\/Users\/tippang\/PycharmProjects\/pythonProject2\/tmp&#8217;<br \/>\nraw_data_dirpath = Path(input_folder)<br \/>\nexcel_files = raw_data_dirpath.glob(&#8216;tst*&#8217;)<\/p>\n<p>merge_df2 = pd.DataFrame()<\/p>\n<p>for excel_file in excel_files:<br \/>\nwb = xw.Book(excel_file)<br \/>\nsheet = wb.sheets[&#8216;sheet1&#8217;]\n<p>df = sheet.range(&#8216;A1&#8242;).options(pd.DataFrame, expand=&#8217;table&#8217;, index=False).value<\/p>\n<p>wb.close()<\/p>\n<p>merge_df2 = merge_df2.append(df, ignore_index=True)<\/p>\n<p>merged_excel_file = input_folder + &#8216;integrated_file2.xlsx&#8217;<br \/>\nmerge_df2.to_excel(merged_excel_file, sheet_name=&#8217;1Q_Data&#8217;, index=False)<\/p>\n<p>print(&#8220;crated file&#8221;, merged_excel_file)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a min, you can data manipulation as Excel &amp; Python Expert<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"footnotes":""},"categories":[17,6,18],"tags":[],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-excel","category-officetool","category-python"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to merge a few excel files into one (Python+Excel method #2, w\/xlwings) - tippang.net<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tippang.net\/?p=592\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"og:locale\" content=\"en_US\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"og:type\" content=\"article\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"og:title\" content=\"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings) - tippang.net\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"og:description\" content=\"In a min, you can data manipulation as Excel &amp; Python Expert\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tippang.net\/?p=592\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"og:site_name\" content=\"tippang.net\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-09T05:09:59+00:00\" class=\"yoast-seo-meta-tag\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-10T10:01:59+00:00\" class=\"yoast-seo-meta-tag\" \/>\n<meta name=\"author\" content=\"Charles\" class=\"yoast-seo-meta-tag\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" class=\"yoast-seo-meta-tag\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" class=\"yoast-seo-meta-tag\" \/>\n\t<meta name=\"twitter:data1\" content=\"Charles\" class=\"yoast-seo-meta-tag\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" class=\"yoast-seo-meta-tag\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" class=\"yoast-seo-meta-tag\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/tippang.net\/?p=592#article\",\"isPartOf\":{\"@id\":\"https:\/\/tippang.net\/?p=592\"},\"author\":{\"name\":\"Charles\",\"@id\":\"https:\/\/tippang.net\/#\/schema\/person\/d1b0d568e5385a89b638f3eedf2dca86\"},\"headline\":\"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings)\",\"datePublished\":\"2022-03-09T05:09:59+00:00\",\"dateModified\":\"2022-03-10T10:01:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/tippang.net\/?p=592\"},\"wordCount\":229,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/tippang.net\/#organization\"},\"articleSection\":[\"Excel\",\"OFFICETOOL\",\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/tippang.net\/?p=592#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tippang.net\/?p=592\",\"url\":\"https:\/\/tippang.net\/?p=592\",\"name\":\"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings) - tippang.net\",\"isPartOf\":{\"@id\":\"https:\/\/tippang.net\/#website\"},\"datePublished\":\"2022-03-09T05:09:59+00:00\",\"dateModified\":\"2022-03-10T10:01:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/tippang.net\/?p=592#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tippang.net\/?p=592\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tippang.net\/?p=592#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tippang.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tippang.net\/#website\",\"url\":\"https:\/\/tippang.net\/\",\"name\":\"tippang.net\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/tippang.net\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tippang.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/tippang.net\/#organization\",\"name\":\"tippang.net\",\"url\":\"https:\/\/tippang.net\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tippang.net\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/tippang.net\/wp-content\/uploads\/2021\/02\/cropped-\u110e\u1162\u1102\u1165\u11af\u110b\u1161\u110b\u1175\u110f\u1169\u11ab1_\u1100\u1165\u1107\u116e\u11a8\u110b\u1175.png\",\"contentUrl\":\"https:\/\/tippang.net\/wp-content\/uploads\/2021\/02\/cropped-\u110e\u1162\u1102\u1165\u11af\u110b\u1161\u110b\u1175\u110f\u1169\u11ab1_\u1100\u1165\u1107\u116e\u11a8\u110b\u1175.png\",\"width\":280,\"height\":280,\"caption\":\"tippang.net\"},\"image\":{\"@id\":\"https:\/\/tippang.net\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/tippang.net\/#\/schema\/person\/d1b0d568e5385a89b638f3eedf2dca86\",\"name\":\"Charles\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tippang.net\/#\/schema\/person\/image\/\",\"url\":\"\/\/www.gravatar.com\/avatar\/3a452b00f5e85211cbb28d2708d7f18f?s=96&#038;r=g&#038;d=wavatar\",\"contentUrl\":\"\/\/www.gravatar.com\/avatar\/3a452b00f5e85211cbb28d2708d7f18f?s=96&#038;r=g&#038;d=wavatar\",\"caption\":\"Charles\"},\"description\":\"An IT Guy On earth\",\"sameAs\":[\"https:\/\/www.tiptip.today\"],\"url\":\"https:\/\/tippang.net\/author\/cm201705\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings) - tippang.net","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tippang.net\/?p=592","og_locale":"en_US","og_type":"article","og_title":"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings) - tippang.net","og_description":"In a min, you can data manipulation as Excel &amp; Python Expert","og_url":"https:\/\/tippang.net\/?p=592","og_site_name":"tippang.net","article_published_time":"2022-03-09T05:09:59+00:00","article_modified_time":"2022-03-10T10:01:59+00:00","author":"Charles","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Charles","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tippang.net\/?p=592#article","isPartOf":{"@id":"https:\/\/tippang.net\/?p=592"},"author":{"name":"Charles","@id":"https:\/\/tippang.net\/#\/schema\/person\/d1b0d568e5385a89b638f3eedf2dca86"},"headline":"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings)","datePublished":"2022-03-09T05:09:59+00:00","dateModified":"2022-03-10T10:01:59+00:00","mainEntityOfPage":{"@id":"https:\/\/tippang.net\/?p=592"},"wordCount":229,"commentCount":0,"publisher":{"@id":"https:\/\/tippang.net\/#organization"},"articleSection":["Excel","OFFICETOOL","Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/tippang.net\/?p=592#respond"]}]},{"@type":"WebPage","@id":"https:\/\/tippang.net\/?p=592","url":"https:\/\/tippang.net\/?p=592","name":"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings) - tippang.net","isPartOf":{"@id":"https:\/\/tippang.net\/#website"},"datePublished":"2022-03-09T05:09:59+00:00","dateModified":"2022-03-10T10:01:59+00:00","breadcrumb":{"@id":"https:\/\/tippang.net\/?p=592#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tippang.net\/?p=592"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tippang.net\/?p=592#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tippang.net\/"},{"@type":"ListItem","position":2,"name":"How to merge a few excel files into one (Python+Excel method #2, w\/xlwings)"}]},{"@type":"WebSite","@id":"https:\/\/tippang.net\/#website","url":"https:\/\/tippang.net\/","name":"tippang.net","description":"","publisher":{"@id":"https:\/\/tippang.net\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tippang.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/tippang.net\/#organization","name":"tippang.net","url":"https:\/\/tippang.net\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tippang.net\/#\/schema\/logo\/image\/","url":"https:\/\/tippang.net\/wp-content\/uploads\/2021\/02\/cropped-\u110e\u1162\u1102\u1165\u11af\u110b\u1161\u110b\u1175\u110f\u1169\u11ab1_\u1100\u1165\u1107\u116e\u11a8\u110b\u1175.png","contentUrl":"https:\/\/tippang.net\/wp-content\/uploads\/2021\/02\/cropped-\u110e\u1162\u1102\u1165\u11af\u110b\u1161\u110b\u1175\u110f\u1169\u11ab1_\u1100\u1165\u1107\u116e\u11a8\u110b\u1175.png","width":280,"height":280,"caption":"tippang.net"},"image":{"@id":"https:\/\/tippang.net\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/tippang.net\/#\/schema\/person\/d1b0d568e5385a89b638f3eedf2dca86","name":"Charles","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tippang.net\/#\/schema\/person\/image\/","url":"\/\/www.gravatar.com\/avatar\/3a452b00f5e85211cbb28d2708d7f18f?s=96&#038;r=g&#038;d=wavatar","contentUrl":"\/\/www.gravatar.com\/avatar\/3a452b00f5e85211cbb28d2708d7f18f?s=96&#038;r=g&#038;d=wavatar","caption":"Charles"},"description":"An IT Guy On earth","sameAs":["https:\/\/www.tiptip.today"],"url":"https:\/\/tippang.net\/author\/cm201705"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/tippang.net\/index.php?rest_route=\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tippang.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tippang.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tippang.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tippang.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=592"}],"version-history":[{"count":5,"href":"https:\/\/tippang.net\/index.php?rest_route=\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":604,"href":"https:\/\/tippang.net\/index.php?rest_route=\/wp\/v2\/posts\/592\/revisions\/604"}],"wp:attachment":[{"href":"https:\/\/tippang.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tippang.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tippang.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}