Name | xlparser JSON |
Version |
0.6.1
JSON |
| download |
home_page | None |
Summary | Parse excel(xlsx/xls/csv) to other format(csv, xlsx, json). |
upload_time | 2024-07-20 10:27:26 |
maintainer | None |
docs_url | None |
author | ahuigo |
requires_python | >=3.9 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
- [xlparser](#xlparser)
- [Install](#install)
- [Usage](#usage)
- [CLI Usage](#cli-usage)
- [Module Usage](#module-usage)
- [Parse any type of file](#parse-any-type-of-file)
- [Save to any type of file](#save-to-any-type-of-file)
- [Csv operation](#csv-operation)
- [Zip operation](#zip-operation)
- [Required](#required)
# xlparser
Parse excel(xlsx/xls/csv) to other format(csv, xlsx, json).
[![](https://img.shields.io/pypi/pyversions/xlparser.svg?longCache=True)](https://pypi.org/pypi/xlparser/)
[![](https://img.shields.io/pypi/v/xlparser.svg?maxAge=36000)](https://pypi.org/pypi/xlparser/)
## Install
pip install xlparser
# or
pip3 install xlparser
If you want to filter fields, it will be convenient with [xcut](https://github.com/ahuigo/xcut).
pip install xcut
# or
pip3 install xcut
## Usage
$ xlparser -h
xlparser [options] INFILE [OUTFILE]\n
options:\n
-h For help.\n
### CLI Usage
From xlsx to csv.
$ xlparser source.xlsx new.csv
From csv to xlsx.
$ xlparser source.csv new.xlsx
From csv to json.
$ xlparser source.csv new.json
From xlsx to csv(stdout).
$ xlparser source.xlsx | head
$ xlparser src.xlsx | tee test.csv
name, score
"李雷,韩梅",15
小花,16
Use xcut to filter fields.
$ xlparser src.xlsx | xcut --from-csv -f name
name
"李雷,韩梅"
小花
$ xlparser src.xlsx | xcut --from-csv -f score,name
score,name
15,"李雷,韩梅"
16,小花
Convert xlsx to csv
$ xlparser src.xlsx test.csv;
$ cat test.csv
name, age
李雷,15
小花,16
Convert csv to json
$ xlparser test.csv test.json
[["name", "age"], ["李雷", "15"], ["小花", "16"]]
### Module Usage
#### Parse any type of file
`parse` any type of file to rows:
>>> from xlparser import parse, saveCsv
>>> rows = parse('some.xlsx')
>>> list(rows)
[['foo', 'bar'], ['看', '我', '变']]
The `parse` function supports the following file formats: .csv, .xls, .xlsx .
#### Save to any type of file
Save rows to csv
>>> from xlparser import saveCsv
>>> rows = [['foo', 'bar'], ['看', '我', '变']]
>>> saveCsv(rows, 'test.csv')
Save rows to xlsx
>>> saveXlsx(rows, 'test.xlsx')
#### Csv operation
>>> from xlparser import *
>>> rows = [('foo','bar'), ('看','我','变')]
>>> saveCsv(rows, 'test.csv')
>>> list(parseCsv('test.csv'))
[['foo', 'bar'], ['看', '我', '变']]
#### Zip operation
>>> from xlparser import loadZip
>>> zf = loadZip('test.xlsx')
>>> print(zf.filelist)
......
>>> zf.extract('xl/media/image1.png', '/tmp')
>>> os.rename('/tmp/'+'xl/media/image1.png', './image1.png')
## Required
1. python>=3.5
2. xlrd: required by xls
2. openpyxl>=2.5.4: required by xlsx
Raw data
{
"_id": null,
"home_page": null,
"name": "xlparser",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "ahuigo",
"author_email": "1781999+ahuigo@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/7e/a7/c8927b7c2b29fc6f69710579ba30a4a4ff7c1441ed6313fa3eafbfea45fa/xlparser-0.6.1.tar.gz",
"platform": null,
"description": "- [xlparser](#xlparser)\n - [Install](#install)\n - [Usage](#usage)\n - [CLI Usage](#cli-usage)\n - [Module Usage](#module-usage)\n - [Parse any type of file](#parse-any-type-of-file)\n - [Save to any type of file](#save-to-any-type-of-file)\n - [Csv operation](#csv-operation)\n - [Zip operation](#zip-operation)\n - [Required](#required)\n\n# xlparser\nParse excel(xlsx/xls/csv) to other format(csv, xlsx, json).\n\n\n[![](https://img.shields.io/pypi/pyversions/xlparser.svg?longCache=True)](https://pypi.org/pypi/xlparser/)\n[![](https://img.shields.io/pypi/v/xlparser.svg?maxAge=36000)](https://pypi.org/pypi/xlparser/)\n\n## Install\n\n pip install xlparser\n # or\n pip3 install xlparser\n\nIf you want to filter fields, it will be convenient with [xcut](https://github.com/ahuigo/xcut).\n\n pip install xcut \n # or\n pip3 install xcut \n\n## Usage\n\n $ xlparser -h\n xlparser [options] INFILE [OUTFILE]\\n\n options:\\n\n -h For help.\\n\n\n### CLI Usage\nFrom xlsx to csv.\n\n $ xlparser source.xlsx new.csv \n\nFrom csv to xlsx.\n\n $ xlparser source.csv new.xlsx \n\nFrom csv to json.\n\n $ xlparser source.csv new.json\n\nFrom xlsx to csv(stdout).\n\n $ xlparser source.xlsx | head \n\n $ xlparser src.xlsx | tee test.csv\n name, score\n \"\u674e\u96f7,\u97e9\u6885\",15\n \u5c0f\u82b1,16\n\nUse xcut to filter fields.\n\n $ xlparser src.xlsx | xcut --from-csv -f name \n name\n \"\u674e\u96f7,\u97e9\u6885\"\n \u5c0f\u82b1\n\n $ xlparser src.xlsx | xcut --from-csv -f score,name\n score,name\n 15,\"\u674e\u96f7,\u97e9\u6885\"\n 16,\u5c0f\u82b1\n\nConvert xlsx to csv\n\n $ xlparser src.xlsx test.csv; \n $ cat test.csv\n name, age\n \u674e\u96f7,15\n \u5c0f\u82b1,16\n\nConvert csv to json\n\n $ xlparser test.csv test.json\n [[\"name\", \"age\"], [\"\u674e\u96f7\", \"15\"], [\"\u5c0f\u82b1\", \"16\"]]\n\n### Module Usage\n\n#### Parse any type of file\n`parse` any type of file to rows:\n\n >>> from xlparser import parse, saveCsv\n >>> rows = parse('some.xlsx')\n >>> list(rows)\n [['foo', 'bar'], ['\u770b', '\u6211', '\u53d8']]\n\nThe `parse` function supports the following file formats: .csv, .xls, .xlsx .\n\n#### Save to any type of file\nSave rows to csv\n\n >>> from xlparser import saveCsv\n >>> rows = [['foo', 'bar'], ['\u770b', '\u6211', '\u53d8']]\n >>> saveCsv(rows, 'test.csv')\n\nSave rows to xlsx\n\n >>> saveXlsx(rows, 'test.xlsx')\n\n#### Csv operation\n\n >>> from xlparser import *\n\n >>> rows = [('foo','bar'), ('\u770b','\u6211','\u53d8')]\n >>> saveCsv(rows, 'test.csv')\n\n >>> list(parseCsv('test.csv'))\n [['foo', 'bar'], ['\u770b', '\u6211', '\u53d8']]\n\n#### Zip operation\n\n >>> from xlparser import loadZip\n >>> zf = loadZip('test.xlsx')\n >>> print(zf.filelist)\n ......\n >>> zf.extract('xl/media/image1.png', '/tmp')\n >>> os.rename('/tmp/'+'xl/media/image1.png', './image1.png')\n\n## Required\n1. python>=3.5\n2. xlrd: required by xls\n2. openpyxl>=2.5.4: required by xlsx\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parse excel(xlsx/xls/csv) to other format(csv, xlsx, json).",
"version": "0.6.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4ea2613514190de98111f738cf86534ffeb074d090148c1ecda10fe5308e7e30",
"md5": "f9f0682203866f6a7a5b9e8ffb5b15fd",
"sha256": "68e33c520ce6704817c713e765f35618f0b368e114b50ce4cb06ee259d8364dc"
},
"downloads": -1,
"filename": "xlparser-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9f0682203866f6a7a5b9e8ffb5b15fd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 7656,
"upload_time": "2024-07-20T10:27:24",
"upload_time_iso_8601": "2024-07-20T10:27:24.772125Z",
"url": "https://files.pythonhosted.org/packages/4e/a2/613514190de98111f738cf86534ffeb074d090148c1ecda10fe5308e7e30/xlparser-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7ea7c8927b7c2b29fc6f69710579ba30a4a4ff7c1441ed6313fa3eafbfea45fa",
"md5": "e8cec5bc484956db394cc09247e32a17",
"sha256": "2427ec8d777f67601890287e7ae2c90c565cae67db87a4348413c80e79d24040"
},
"downloads": -1,
"filename": "xlparser-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "e8cec5bc484956db394cc09247e32a17",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 6395,
"upload_time": "2024-07-20T10:27:26",
"upload_time_iso_8601": "2024-07-20T10:27:26.416913Z",
"url": "https://files.pythonhosted.org/packages/7e/a7/c8927b7c2b29fc6f69710579ba30a4a4ff7c1441ed6313fa3eafbfea45fa/xlparser-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-20 10:27:26",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "xlparser"
}