{"id":18020725,"url":"https://github.com/inforkgodara/generate-bulk-documents-python","last_synced_at":"2025-08-17T23:31:54.340Z","repository":{"id":110249734,"uuid":"376299905","full_name":"inforkgodara/generate-bulk-documents-python","owner":"inforkgodara","description":"It is a python script that generates bulk documents automatically from excel sheet data using replace concept.","archived":false,"fork":false,"pushed_at":"2021-07-04T17:02:40.000Z","size":130,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-30T08:21:16.025Z","etag":null,"topics":["automation","bulk","bulk-cards","bulk-certificates","bulk-documents","bulk-letters","cards","document","document-generator","excel","generator","letters","pandas","python","python-docx","python-script","python3","sheet","word","xlrd"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inforkgodara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-12T13:44:18.000Z","updated_at":"2023-11-26T16:08:47.000Z","dependencies_parsed_at":"2023-04-04T01:33:06.894Z","dependency_job_id":null,"html_url":"https://github.com/inforkgodara/generate-bulk-documents-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fgenerate-bulk-documents-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fgenerate-bulk-documents-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fgenerate-bulk-documents-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fgenerate-bulk-documents-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inforkgodara","download_url":"https://codeload.github.com/inforkgodara/generate-bulk-documents-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230181379,"owners_count":18185930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bulk","bulk-cards","bulk-certificates","bulk-documents","bulk-letters","cards","document","document-generator","excel","generator","letters","pandas","python","python-docx","python-script","python3","sheet","word","xlrd"],"created_at":"2024-10-30T06:07:26.301Z","updated_at":"2024-12-17T20:44:08.874Z","avatar_url":"https://github.com/inforkgodara.png","language":"Python","readme":"# Generate Bulk Documents Python\n\nIt is a python script that generate bulk documents automatically from excel sheet data using replace concept. It can be used to generate bulk documents like letters, cards and certificates. It read data from an excel sheet and generate multiple documents.\n\n## Demo\n* Video clip on youtube of the script execution. https://youtu.be/SBubFoe84M0\n\n## Important Note\n* If this repository helped you to understand at least something new please give star this repository which motivates me to work further for the similar kinds for projects.\n\n## Prerequisites\n\nIn order to run the python script, your system must have the following programs/packages installed.\n* Python 3.8: Download it from https://www.python.org/downloads\n* Pandas : Run in command prompt **pip install pandas**\n* Xlrd : Run in command prompt **pip install xlrd**\n* python-docx: Run in command prompt **pip install python-docx**\n\n## Approach\n* First need to clone this respiratory.\n* Run python script which is in script.py using py script.py\n* The script reads data from excel sheet, replace texts and generate documents.\n* Loop execute until and unless all rows completes in excel sheet.\n\n## Code\n```\nimport pyautogui\nimport pandas\nimport datetime\nimport time\nfrom docx import Document\nimport os\n\n# Author @inforkgodara\n\n# Read data from excel\nexcel_data = pandas.read_excel('data.xlsx', sheet_name='Recipient Details')\ncount = 0\ndirectory = 'generated letters'\n\ndef replaceWord(oldString, newString, paragraph):\n    if oldString in paragraph:\n        inline = p.runs\n        # Loop added to work with runs (strings with same style)\n        for i in range(len(inline)):\n            if oldString in inline[i].text:\n                text = inline[i].text.replace(oldString, newString)\n                inline[i].text = text\n\n# Iterate excel rows till to finish\nfor column in excel_data['Recipient Full Name'].tolist():\n    document = Document('letter template.docx')\n    doc = document\n    empName = excel_data['Recipient Full Name'][count]\n    for p in doc.paragraphs:\n        replaceWord('RECIPIENT NAME', excel_data['Recipient Full Name'][count], p.text)\n        replaceWord('FIRST NAME', excel_data['Recipient First Name'][count], p.text)\n        replaceWord('TITLE', excel_data['Recipient Title'][count], p.text)\n        replaceWord('COMPANY NAME', excel_data['Recipient Company Name'][count], p.text)\n        replaceWord('STREET ADDRESS', excel_data['Recipient Street Address'][count], p.text)\n        replaceWord('CITY, ST ZIP CODE', str(excel_data['Recipient City, ST ZIP Code'][count]), p.text)\n\n    try:\n        path = os.getcwd()+\"/\"+directory+\"/\"+empName\n        os.mkdir(path)\n    except OSError:\n        a = 10\n    doc.save(os.getcwd()+\"/\"+directory+\"/\"+empName+\"/\"+empName+' Latter.docx')\n    print(\"Letter generated for \" + empName)\n    count = count + 1\n\nprint(\"Total letters are created \" + str(count))\n```\nVideo on youtube: https://youtu.be/SBubFoe84M0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforkgodara%2Fgenerate-bulk-documents-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finforkgodara%2Fgenerate-bulk-documents-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforkgodara%2Fgenerate-bulk-documents-python/lists"}