{"id":22665253,"url":"https://github.com/volkansah/python-command-overview-for-handling-files","last_synced_at":"2025-09-13T16:21:50.333Z","repository":{"id":180145482,"uuid":"664650424","full_name":"VolkanSah/Python-Command-Overview-for-handling-files","owner":"VolkanSah","description":"This project serves as a comprehensive guide to executing shell commands and handling files using Python.","archived":false,"fork":false,"pushed_at":"2024-05-19T17:35:54.000Z","size":496,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T20:41:39.212Z","etag":null,"topics":["commands","commands-cheat-sheet","commands-git","csv","exel","files","html","learning-python","pdf","python","python-3","python-for-beginners","python-for-data-analysis","python-for-everybody","python-for-hacking","python3","word"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VolkanSah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["volkansah"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-07-10T12:53:46.000Z","updated_at":"2024-05-28T17:29:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"2136dace-adbb-4daf-9327-eb34810fb851","html_url":"https://github.com/VolkanSah/Python-Command-Overview-for-handling-files","commit_stats":null,"previous_names":["volkansah/python-command-overview-for-handling-files"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VolkanSah/Python-Command-Overview-for-handling-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FPython-Command-Overview-for-handling-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FPython-Command-Overview-for-handling-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FPython-Command-Overview-for-handling-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FPython-Command-Overview-for-handling-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VolkanSah","download_url":"https://codeload.github.com/VolkanSah/Python-Command-Overview-for-handling-files/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FPython-Command-Overview-for-handling-files/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274990279,"owners_count":25386622,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["commands","commands-cheat-sheet","commands-git","csv","exel","files","html","learning-python","pdf","python","python-3","python-for-beginners","python-for-data-analysis","python-for-everybody","python-for-hacking","python3","word"],"created_at":"2024-12-09T13:29:46.096Z","updated_at":"2025-09-13T16:21:50.291Z","avatar_url":"https://github.com/VolkanSah.png","language":null,"funding_links":["https://github.com/sponsors/volkansah"],"categories":[],"sub_categories":[],"readme":"# Python Command Overview for handling files\n[Webview](https://volkansah.github.io/Python-Command-Overview-for-handling-files/)\n![Python comman overview for big files](python_large_commands.png)\n\nThis project serves as a comprehensive guide to executing shell commands and handling files using Python.\nInstallation. \n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Install Requirements](#Install-requirements)\n- [Shell Commands with Python](#shell-commands-with-python)\n  - [Creating and writing to a file](#creating-and-writing-to-a-file)\n  - [Reading from a file](#reading-from-a-file)\n  - [Appending to an existing file](#appending-to-an-existing-file)\n  - [Deleting a file](#deleting-a-file)\n  - [Checking if a file exists](#checking-if-a-file-exists)\n  - [Creating a directory](#creating-a-directory)\n- [Large File Handling](#large-file-handling)\n  - [Opening a file](#opening-a-file)\n  - [Reading a file line by line](#reading-a-file-line-by-line)\n  - [Reading a specific number of lines](#reading-a-specific-number-of-lines)\n  - [Searching within a large file](#searching-within-a-large-file)\n  - [Writing to a large file](#writing-to-a-large-file)\n  - [Splitting files](#splitting-files)\n- [Handling Specific File Formats](#handling-specific-file-formats)\n  - [Reading PDF files](#reading-pdf-files)\n  - [Reading Word documents](#reading-word-documents)\n  - [Reading Excel files](#reading-excel-files)\n  - [Reading HTML files](#reading-html-files)\n- [Credits](#credits)\n- [Useful Resources](#useful-resources)\n\n\n\n\n\n## Installation\nYou can install Python through the official website: https://www.python.org/downloads/\n\n#### Requiments\n```python\npip install PyPDF2 python-docx pandas beautifulsoup4\n```\n## Usage\nThis project can be used as a reference guide for executing shell commands and file handling in Python.\nShell Commands with Python\n\nThis project makes use of Python to execute shell commands. Here are some of the Python commands used in this project:\n\n## Creating and writing to a file\n\n```python\n\nwith open(\"filename.txt\", \"w\") as f:\n    f.write(\"Hello, World!\")\n```\n### Reading from a file\n\n```python\n\nwith open(\"filename.txt\", \"r\") as f:\n    print(f.read())\n```\n### Appending to an existing file\n\n```python\n\nwith open(\"filename.txt\", \"a\") as f:\n    f.write(\"More text.\")\n```\n### Deleting a file\n\n```python\n\nimport os\nos.remove(\"filename.txt\")\n```\n### Checking if a file exists\n\n```python\n\nimport os\nos.path.exists(\"filename.txt\")\n```\n### Creating a directory\n\n```python\nimport os\nos.mkdir(\"directory_name\")\n```\n## Large File Handling\n\nWorking with large files requires a different set of Python commands. Here are some examples:\n\n### Opening a file\n\n```python\n\nfile = open('large_file.txt', 'r')\n```\n### Reading a file line by line\n\n```python\n\nwith open('large_file.txt', 'r') as file:\n    for line in file:\n        print(line)\n```\n### Reading a specific number of lines\n\n```python\n\nfrom itertools import islice\nwith open('large_file.txt', 'r') as file:\n    head = list(islice(file, 5))\n```\n### Searching within a large file\n\n```python\n\nwith open('large_file.txt', 'r') as file:\n    for line in file:\n        if 'some_text' in line:\n            print(line)\n```\n### Writing to a large file\n\n```python\n\nwith open('large_file.txt', 'w') as file:\n    file.write('some_text')\n```\n### Splitting files\n\n```python\n\nchunk_size = 1000000  # 1 MB\nwith open('large_file.txt', 'r') as file:\n    chunk = file.read(chunk_size)\n    while chunk:\n        with open('chunk.txt', 'w') as chunk_file:\n            chunk_file.write(chunk)\n        chunk = file.read(chunk_size)\n```\n## Handling Specific File Formats\n\nPython can read various file formats using specific libraries. Here are some examples:\n\n### Reading PDF files\n\n```python\n\nimport PyPDF2\n\nwith open('example.pdf', 'rb') as file:\n    reader = PyPDF2.PdfFileReader(file)\n    page = reader.getPage(0)\n    print(page.extract_text())\n```\n### Reading Word documents\n\n```python\n\nfrom docx import Document\n\ndoc = Document('example.docx')\nfor para in doc.paragraphs:\n    print(para.text)\n```\n### Reading Excel files\n\n```python\n\nimport pandas as pd\n\ndata = pd.read_excel('example.xlsx')\nprint(data)\n```\n### Reading HTML files\n\n```python\n\nfrom bs4 import BeautifulSoup\n\nwith open(\"example.html\") as fp:\n    soup = BeautifulSoup(fp, 'html.parser')\nprint(soup.prettify())\n```\n## Credits\nThis README was generated with the help of ChatGPT4, an AI developed by OpenAI \u0026 [Volkan Sah](https://github.com/volkansah).\n\n## Usefull\n- [Python Modul Overview](https://github.com/VolkanSah/Python-Modules-Overview)\n- [Python XPath Tutorial](https://github.com/VolkanSah/Python-XPath-Tutorial)\n- [Source](https://github.com/VolkanSah/Python-Command-Overview-for-handling-files)\n\n## ❤️ Thank you for your support!\nIf you appreciate my work, please consider supporting me:\n\n- Become a Sponsor: [Link to my sponsorship page](https://github.com/sponsors/volkansah)\n- :star: my projects: Starring projects on GitHub helps increase their visibility and can help others find my work. \n- Follow me: Stay updated with my latest projects and releases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolkansah%2Fpython-command-overview-for-handling-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolkansah%2Fpython-command-overview-for-handling-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolkansah%2Fpython-command-overview-for-handling-files/lists"}