in2xl


Namein2xl JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/gozred/python-in2xl
SummaryA package that allows to insert data in an XLSX file without changing the layout.
upload_time2023-04-04 18:43:34
maintainer
docs_urlNone
authorHerzog(gozred)
requires_python
licenseMIT License
keywords python xlsx excel dataframe insert in excel template excel template
VCS
bugtrack_url
requirements openpyxl xlsxwriter ruamel.std.zipfile lxml pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # in2xl

## About this project

In the Python programming language, there exist various proficient tools
to write data to XLSX format. Two of the most commonly used tools are
[XlsxWriter](https://pypi.org/project/XlsxWriter/) and
[openpyxl](https://pypi.org/project/openpyxl). With these tools, one can
conveniently create an Excel file or write data to an existing Excel
file. However, there are some limitations to be aware of when using
these tools. Specifically,
[XlsxWriter](https://pypi.org/project/XlsxWriter/) is capable of
creating files but not modifying them, whereas
[openpyxl](https://pypi.org/project/openpyxl) can modify files but does
not retain all formatting.

In the data science domain, such limitations can pose challenges,
especially if employees have significantly edited Excel files and only
require updated data. To address this issue, in2xl offers a simplistic
and efficient solution. This tool enables users to transfer data and
data frames directly into an Excel file without affecting the existing
formatting. Hence, in2xl can be a useful tool for data scientists
seeking to update data in pre-existing Excel files.

## Install

in2xl is available on pypi.org. Simply run `pip install in2xl` to
install it.

Requirements: \>= Python 3.7

Project dependencies installed by pip:

>     lxml
>     pandas
>     openpyxl
>     ruamel.std.zipfile
>     XlsxWriter

## Usage

The names of the functions are intentionally adapted to
[openpyxl](https://pypi.org/project/openpyxl) to make them easier to use
and to adapt existing scripts.

### Open a Workbook

It is not possible to create new workbooks using in2xl. The intended
approach is to open an existing Excel file (xlsx), insert data, and save
it. The opened file serves as a template, where a copy is generated and
modified to suit the requirements.

*Example 1:*

``` python
from in2xl import Workbook

wb = Workbook().load_workbook(path)
```

But this method is also possible:

*Example 2:*

``` python
import in2xl as ix

wb = ix.load_workbook(path)
```

### Open a Worksheet

``` python
ws = wb[sheetname]
```

Additionally you can check the names of all worksheets

``` python
print(wb.sheetnames)
```

### Insert data

Different types of data can be inserted directly via `insert()`

``` python
ws.insert(df, 2, 3, header=False)
```

More detailed description of this function:

*insert(data, row=1, column=1, axis=0, header=True, index=False)*

> Parameters:
>
>
>     data: Union(str, int, float, decimal, pd.DataFrame)
>
>         Besides strings and real numbers, DataFrames can also be
>         inserted directly.
>
>     row: int
>
>         The row in which the data is to be inserted. The default is
>         the first row.
>
>     column: int
>
>         The column in which the data is to be inserted. The default is
>         the first column.
>
>     axis: int
>
>         Specify whether the data is inserted in the original
>         orientation or a transposed direction. Default is 0
>         0 : If the data is in a vertical orientation, it will be inserted
>         vertically.
>         1 : If the data is in a vertical orientation, it will be inserted
>         horizontally.
>
>     header: bool
>
>         True to include headers in the data, False otherwise. Default
>         is True.
>
>     index: bool
>
>         True to include index in the data, False otherwise. Defaults
>         to False.
>
>     ignore_nan:  bool
>
>         True to include nan-values in the data, False otherwise. Defaults
>         to True.

### Save & Close

``` python
ws.save(path)
ws.close()
```

The file can be saved multiple times (under different names). As long as
the file has not been closed, the temporary Excel file exists. The close
command deletes this temporary file.

### Additional functions

Template files are sometimes created for multiple tasks/situations. Not
all worksheets are always necessary for this. To be able to use these
files anyway, it is possible to hide these worksheets.

``` python
print(wb.wb_state) # Returns the visibility status of all worksheets
print(ws.state) # Returns the visibility status of the current worksheet

ws.state = 0 # Sets the visibility status to 'visible'.
ws.state = 1 # Sets the visibility status to 'hidden'. User can make this worksheet visible again out of Excel via "Unhide".
ws.state = 2 # Sets the visibility status to 'veryHidden'. Worksheet is not visible under "Unhide" in Excel.
```

### Planned further functions

-   Insert Data into tables / update range of the tables
-   Refresh Data of a pivot table
-   delete worksheets



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gozred/python-in2xl",
    "name": "in2xl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,xlsx,excel,dataframe,insert in excel,template,excel template",
    "author": "Herzog(gozred)",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/75/3c/c4a1d5a41e90846f1d5d27477a13381587c8f748d7a9f952f13c9874dc6f/in2xl-0.2.3.tar.gz",
    "platform": null,
    "description": "# in2xl\r\n\r\n## About this project\r\n\r\nIn the Python programming language, there exist various proficient tools\r\nto write data to XLSX format. Two of the most commonly used tools are\r\n[XlsxWriter](https://pypi.org/project/XlsxWriter/) and\r\n[openpyxl](https://pypi.org/project/openpyxl). With these tools, one can\r\nconveniently create an Excel file or write data to an existing Excel\r\nfile. However, there are some limitations to be aware of when using\r\nthese tools. Specifically,\r\n[XlsxWriter](https://pypi.org/project/XlsxWriter/) is capable of\r\ncreating files but not modifying them, whereas\r\n[openpyxl](https://pypi.org/project/openpyxl) can modify files but does\r\nnot retain all formatting.\r\n\r\nIn the data science domain, such limitations can pose challenges,\r\nespecially if employees have significantly edited Excel files and only\r\nrequire updated data. To address this issue, in2xl offers a simplistic\r\nand efficient solution. This tool enables users to transfer data and\r\ndata frames directly into an Excel file without affecting the existing\r\nformatting. Hence, in2xl can be a useful tool for data scientists\r\nseeking to update data in pre-existing Excel files.\r\n\r\n## Install\r\n\r\nin2xl is available on pypi.org. Simply run `pip install in2xl` to\r\ninstall it.\r\n\r\nRequirements: \\>= Python 3.7\r\n\r\nProject dependencies installed by pip:\r\n\r\n>     lxml\r\n>     pandas\r\n>     openpyxl\r\n>     ruamel.std.zipfile\r\n>     XlsxWriter\r\n\r\n## Usage\r\n\r\nThe names of the functions are intentionally adapted to\r\n[openpyxl](https://pypi.org/project/openpyxl) to make them easier to use\r\nand to adapt existing scripts.\r\n\r\n### Open a Workbook\r\n\r\nIt is not possible to create new workbooks using in2xl. The intended\r\napproach is to open an existing Excel file (xlsx), insert data, and save\r\nit. The opened file serves as a template, where a copy is generated and\r\nmodified to suit the requirements.\r\n\r\n*Example 1:*\r\n\r\n``` python\r\nfrom in2xl import Workbook\r\n\r\nwb = Workbook().load_workbook(path)\r\n```\r\n\r\nBut this method is also possible:\r\n\r\n*Example 2:*\r\n\r\n``` python\r\nimport in2xl as ix\r\n\r\nwb = ix.load_workbook(path)\r\n```\r\n\r\n### Open a Worksheet\r\n\r\n``` python\r\nws = wb[sheetname]\r\n```\r\n\r\nAdditionally you can check the names of all worksheets\r\n\r\n``` python\r\nprint(wb.sheetnames)\r\n```\r\n\r\n### Insert data\r\n\r\nDifferent types of data can be inserted directly via `insert()`\r\n\r\n``` python\r\nws.insert(df, 2, 3, header=False)\r\n```\r\n\r\nMore detailed description of this function:\r\n\r\n*insert(data, row=1, column=1, axis=0, header=True, index=False)*\r\n\r\n> Parameters:\r\n>\r\n>\r\n>     data: Union(str, int, float, decimal, pd.DataFrame)\r\n>\r\n>         Besides strings and real numbers, DataFrames can also be\r\n>         inserted directly.\r\n>\r\n>     row: int\r\n>\r\n>         The row in which the data is to be inserted. The default is\r\n>         the first row.\r\n>\r\n>     column: int\r\n>\r\n>         The column in which the data is to be inserted. The default is\r\n>         the first column.\r\n>\r\n>     axis: int\r\n>\r\n>         Specify whether the data is inserted in the original\r\n>         orientation or a transposed direction. Default is 0\r\n>         0 : If the data is in a vertical orientation, it will be inserted\r\n>         vertically.\r\n>         1 : If the data is in a vertical orientation, it will be inserted\r\n>         horizontally.\r\n>\r\n>     header: bool\r\n>\r\n>         True to include headers in the data, False otherwise. Default\r\n>         is True.\r\n>\r\n>     index: bool\r\n>\r\n>         True to include index in the data, False otherwise. Defaults\r\n>         to False.\r\n>\r\n>     ignore_nan:  bool\r\n>\r\n>         True to include nan-values in the data, False otherwise. Defaults\r\n>         to True.\r\n\r\n### Save & Close\r\n\r\n``` python\r\nws.save(path)\r\nws.close()\r\n```\r\n\r\nThe file can be saved multiple times (under different names). As long as\r\nthe file has not been closed, the temporary Excel file exists. The close\r\ncommand deletes this temporary file.\r\n\r\n### Additional functions\r\n\r\nTemplate files are sometimes created for multiple tasks/situations. Not\r\nall worksheets are always necessary for this. To be able to use these\r\nfiles anyway, it is possible to hide these worksheets.\r\n\r\n``` python\r\nprint(wb.wb_state) # Returns the visibility status of all worksheets\r\nprint(ws.state) # Returns the visibility status of the current worksheet\r\n\r\nws.state = 0 # Sets the visibility status to 'visible'.\r\nws.state = 1 # Sets the visibility status to 'hidden'. User can make this worksheet visible again out of Excel via \"Unhide\".\r\nws.state = 2 # Sets the visibility status to 'veryHidden'. Worksheet is not visible under \"Unhide\" in Excel.\r\n```\r\n\r\n### Planned further functions\r\n\r\n-   Insert Data into tables / update range of the tables\r\n-   Refresh Data of a pivot table\r\n-   delete worksheets\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A package that allows to insert data in an XLSX file without changing the layout.",
    "version": "0.2.3",
    "split_keywords": [
        "python",
        "xlsx",
        "excel",
        "dataframe",
        "insert in excel",
        "template",
        "excel template"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "753cc4a1d5a41e90846f1d5d27477a13381587c8f748d7a9f952f13c9874dc6f",
                "md5": "79aeac0dc8843eb3c2fde18c249a027e",
                "sha256": "224bbfda972ecb1698351e9d5286040e20bbc288181c7504536ca5f6f5610205"
            },
            "downloads": -1,
            "filename": "in2xl-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "79aeac0dc8843eb3c2fde18c249a027e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2836776,
            "upload_time": "2023-04-04T18:43:34",
            "upload_time_iso_8601": "2023-04-04T18:43:34.634412Z",
            "url": "https://files.pythonhosted.org/packages/75/3c/c4a1d5a41e90846f1d5d27477a13381587c8f748d7a9f952f13c9874dc6f/in2xl-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-04 18:43:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "gozred",
    "github_project": "python-in2xl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "openpyxl",
            "specs": []
        },
        {
            "name": "xlsxwriter",
            "specs": []
        },
        {
            "name": "ruamel.std.zipfile",
            "specs": []
        },
        {
            "name": "lxml",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        }
    ],
    "lcname": "in2xl"
}
        
Elapsed time: 1.18623s