csvtojsonify 1.3.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Sriram Sreedhar
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: csvtojsonify
3
+ Version: 2.0.0
4
+ Summary: Convert CSV text to JSON — library, CLI, and optional web UI
5
+ Author-email: Sriram Sreedhar <sriramsreedhar003@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://pypi.org/project/csvtojsonify/
8
+ Project-URL: Repository, https://github.com/sriramsreedhar/csvtojsonify
9
+ Keywords: csv,json,convert
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Provides-Extra: web
21
+ Requires-Dist: fastapi>=0.100.0; extra == "web"
22
+ Requires-Dist: uvicorn[standard]>=0.22.0; extra == "web"
23
+ Dynamic: license-file
24
+
25
+ # csvtojsonify
26
+
27
+ Convert CSV to JSON as a Python library, CLI, or browser UI.
28
+
29
+ ## Install from PyPI
30
+
31
+ ```bash
32
+ pip install csvtojsonify
33
+ ```
34
+
35
+ Web UI (FastAPI + Uvicorn):
36
+
37
+ ```bash
38
+ pip install csvtojsonify[web]
39
+ ```
40
+
41
+ ## Install from source
42
+
43
+ ```bash
44
+ pip install .
45
+ pip install ".[web]"
46
+ ```
47
+
48
+ ## Library
49
+
50
+ ```python
51
+ from csvtojsonify import csv_to_json
52
+
53
+ json_str = csv_to_json("name,age\nAlice,30")
54
+ ```
55
+
56
+ ## CLI
57
+
58
+ ```bash
59
+ csvtojsonify < input.csv > out.json
60
+ csvtojsonify path/to/file.csv
61
+ csvtojsonify --compact < data.csv
62
+ ```
63
+
64
+ ## Web UI
65
+
66
+ ```bash
67
+ csvtojsonify-web
68
+ ```
69
+
70
+ Open http://127.0.0.1:8765 — paste CSV on the left, JSON appears on the right.
71
+
72
+ ## Publishing to PyPI (maintainers)
73
+
74
+ 1. [Create a PyPI account](https://pypi.org/account/register/) and [API token](https://pypi.org/manage/account/token/) (scope: entire account or this project only).
75
+ 2. Install build tools: `pip install build twine`
76
+ 3. Bump the `version` in `pyproject.toml` (and `__version__` in `src/csvtojsonify/__init__.py`) to a **new** number; PyPI rejects re-uploading the same version.
77
+ 5. Build artifacts:
78
+
79
+ ```bash
80
+ python -m build
81
+ ```
82
+
83
+ 6. Upload to the **test** index first (recommended):
84
+
85
+ ```bash
86
+ python -m twine upload --repository testpypi dist/*
87
+ ```
88
+
89
+ Verify: `pip install -i https://test.pypi.org/simple/ csvtojsonify`
90
+
91
+ 7. Upload to **production** PyPI:
92
+
93
+ ```bash
94
+ python -m twine upload dist/*
95
+ ```
96
+
97
+ Configure credentials via `~/.pypirc` or environment variables `TWINE_USERNAME=__token__` and `TWINE_PASSWORD=pypi-...`.
98
+
99
+ After the first release, users install with `pip install csvtojsonify`.
@@ -0,0 +1,75 @@
1
+ # csvtojsonify
2
+
3
+ Convert CSV to JSON as a Python library, CLI, or browser UI.
4
+
5
+ ## Install from PyPI
6
+
7
+ ```bash
8
+ pip install csvtojsonify
9
+ ```
10
+
11
+ Web UI (FastAPI + Uvicorn):
12
+
13
+ ```bash
14
+ pip install csvtojsonify[web]
15
+ ```
16
+
17
+ ## Install from source
18
+
19
+ ```bash
20
+ pip install .
21
+ pip install ".[web]"
22
+ ```
23
+
24
+ ## Library
25
+
26
+ ```python
27
+ from csvtojsonify import csv_to_json
28
+
29
+ json_str = csv_to_json("name,age\nAlice,30")
30
+ ```
31
+
32
+ ## CLI
33
+
34
+ ```bash
35
+ csvtojsonify < input.csv > out.json
36
+ csvtojsonify path/to/file.csv
37
+ csvtojsonify --compact < data.csv
38
+ ```
39
+
40
+ ## Web UI
41
+
42
+ ```bash
43
+ csvtojsonify-web
44
+ ```
45
+
46
+ Open http://127.0.0.1:8765 — paste CSV on the left, JSON appears on the right.
47
+
48
+ ## Publishing to PyPI (maintainers)
49
+
50
+ 1. [Create a PyPI account](https://pypi.org/account/register/) and [API token](https://pypi.org/manage/account/token/) (scope: entire account or this project only).
51
+ 2. Install build tools: `pip install build twine`
52
+ 3. Bump the `version` in `pyproject.toml` (and `__version__` in `src/csvtojsonify/__init__.py`) to a **new** number; PyPI rejects re-uploading the same version.
53
+ 5. Build artifacts:
54
+
55
+ ```bash
56
+ python -m build
57
+ ```
58
+
59
+ 6. Upload to the **test** index first (recommended):
60
+
61
+ ```bash
62
+ python -m twine upload --repository testpypi dist/*
63
+ ```
64
+
65
+ Verify: `pip install -i https://test.pypi.org/simple/ csvtojsonify`
66
+
67
+ 7. Upload to **production** PyPI:
68
+
69
+ ```bash
70
+ python -m twine upload dist/*
71
+ ```
72
+
73
+ Configure credentials via `~/.pypirc` or environment variables `TWINE_USERNAME=__token__` and `TWINE_PASSWORD=pypi-...`.
74
+
75
+ After the first release, users install with `pip install csvtojsonify`.
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "csvtojsonify"
7
+ version = "2.0.0"
8
+ description = "Convert CSV text to JSON — library, CLI, and optional web UI"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Sriram Sreedhar", email = "sriramsreedhar003@gmail.com" }]
14
+ keywords = ["csv", "json", "convert"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://pypi.org/project/csvtojsonify/"
27
+ Repository = "https://github.com/sriramsreedhar/csvtojsonify"
28
+
29
+ [project.scripts]
30
+ csvtojsonify = "csvtojsonify.cli:main"
31
+ csvtojsonify-web = "csvtojsonify.cli:main_web"
32
+
33
+ [project.optional-dependencies]
34
+ web = [
35
+ "fastapi>=0.100.0",
36
+ "uvicorn[standard]>=0.22.0",
37
+ ]
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.setuptools.package-data]
43
+ csvtojsonify = ["web/static/*"]
@@ -0,0 +1,7 @@
1
+ """CSV to JSON conversion — library, CLI, and optional web UI."""
2
+
3
+ from csvtojsonify.core import ConversionError, csv_rows, csv_to_json
4
+
5
+ __all__ = ["ConversionError", "csv_rows", "csv_to_json", "__version__"]
6
+
7
+ __version__ = "2.0.0"
@@ -0,0 +1,56 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import sys
5
+
6
+ from csvtojsonify.core import ConversionError, csv_to_json
7
+
8
+
9
+ def main() -> None:
10
+ parser = argparse.ArgumentParser(description="Convert CSV to JSON (stdout).")
11
+ parser.add_argument(
12
+ "path",
13
+ nargs="?",
14
+ help="CSV file path; omit to read stdin",
15
+ )
16
+ parser.add_argument(
17
+ "--compact",
18
+ action="store_true",
19
+ help="Minified JSON (no indentation)",
20
+ )
21
+ args = parser.parse_args()
22
+
23
+ if args.path:
24
+ with open(args.path, encoding="utf-8") as f:
25
+ text = f.read()
26
+ else:
27
+ text = sys.stdin.read()
28
+
29
+ try:
30
+ out = csv_to_json(text, indent=None if args.compact else 2)
31
+ except ConversionError as e:
32
+ print(f"csvtojsonify: {e}", file=sys.stderr)
33
+ raise SystemExit(1) from e
34
+
35
+ sys.stdout.write(out)
36
+ if not out.endswith("\n"):
37
+ sys.stdout.write("\n")
38
+
39
+
40
+ def main_web() -> None:
41
+ """Run the web UI (requires optional [web] dependencies)."""
42
+ try:
43
+ import uvicorn
44
+ except ImportError as e:
45
+ print(
46
+ "The web UI needs extra packages. Install with: pip install 'csvtojsonify[web]'",
47
+ file=sys.stderr,
48
+ )
49
+ raise SystemExit(1) from e
50
+
51
+ uvicorn.run(
52
+ "csvtojsonify.web.app:app",
53
+ host="127.0.0.1",
54
+ port=8765,
55
+ reload=False,
56
+ )
@@ -0,0 +1,55 @@
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ import io
5
+ import json
6
+
7
+
8
+ class ConversionError(Exception):
9
+ """Raised when CSV input cannot be parsed."""
10
+
11
+
12
+ def _strip_bom(text: str) -> str:
13
+ if text.startswith("\ufeff"):
14
+ return text[1:]
15
+ return text
16
+
17
+
18
+ def csv_rows(csv_text: str) -> list[dict[str, str | None]]:
19
+ """
20
+ Parse CSV text into a list of row dicts (header keys, string values).
21
+ Empty fields become None when using non-empty restkey handling — we keep
22
+ empty strings as "" for JSON-friendly output.
23
+ """
24
+ text = _strip_bom(csv_text).strip()
25
+ if not text:
26
+ return []
27
+
28
+ stream = io.StringIO(text)
29
+ try:
30
+ sample = stream.read(4096)
31
+ stream.seek(0)
32
+ try:
33
+ dialect = csv.Sniffer().sniff(sample, delimiters=",\t;|")
34
+ except csv.Error:
35
+ dialect = csv.excel
36
+ reader = csv.DictReader(stream, dialect=dialect)
37
+ rows: list[dict[str, str | None]] = []
38
+ for row in reader:
39
+ rows.append(
40
+ {k: (v if v is not None else "") for k, v in row.items() if k is not None}
41
+ )
42
+ return rows
43
+ except csv.Error as e:
44
+ raise ConversionError(str(e)) from e
45
+
46
+
47
+ def csv_to_json(
48
+ csv_text: str,
49
+ *,
50
+ indent: int | None = 2,
51
+ ensure_ascii: bool = False,
52
+ ) -> str:
53
+ """Return pretty-printed JSON for the given CSV string."""
54
+ rows = csv_rows(csv_text)
55
+ return json.dumps(rows, indent=indent, ensure_ascii=ensure_ascii)
@@ -0,0 +1 @@
1
+ """Optional FastAPI web UI for csvtojsonify."""
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from fastapi import FastAPI, HTTPException
6
+ from fastapi.middleware.cors import CORSMiddleware
7
+ from fastapi.responses import FileResponse
8
+ from fastapi.staticfiles import StaticFiles
9
+ from pydantic import BaseModel, Field, field_validator
10
+
11
+ from csvtojsonify.core import ConversionError, csv_to_json
12
+
13
+ _STATIC = Path(__file__).resolve().parent / "static"
14
+
15
+ app = FastAPI(title="csvtojsonify", version="2.0.0")
16
+ app.add_middleware(
17
+ CORSMiddleware,
18
+ allow_origins=["*"],
19
+ allow_methods=["*"],
20
+ allow_headers=["*"],
21
+ )
22
+
23
+
24
+ class ConvertRequest(BaseModel):
25
+ csv: str = Field(..., description="Raw CSV text")
26
+ indent: int | None = Field(
27
+ 2,
28
+ description="JSON indent (0–8 spaces); null for minified output",
29
+ )
30
+
31
+ @field_validator("indent")
32
+ @classmethod
33
+ def _indent_range(cls, v: int | None) -> int | None:
34
+ if v is not None and not 0 <= v <= 8:
35
+ raise ValueError("indent must be between 0 and 8, or null")
36
+ return v
37
+
38
+
39
+ class ConvertResponse(BaseModel):
40
+ output: str
41
+
42
+
43
+ @app.get("/api/health")
44
+ def health() -> dict[str, str]:
45
+ return {"status": "ok"}
46
+
47
+
48
+ @app.post("/api/convert", response_model=ConvertResponse)
49
+ def convert(body: ConvertRequest) -> ConvertResponse:
50
+ try:
51
+ text = csv_to_json(body.csv, indent=body.indent)
52
+ except ConversionError as e:
53
+ raise HTTPException(status_code=400, detail=str(e)) from e
54
+ return ConvertResponse(output=text)
55
+
56
+
57
+ @app.get("/")
58
+ def index() -> FileResponse:
59
+ return FileResponse(_STATIC / "index.html")
60
+
61
+
62
+ app.mount(
63
+ "/assets",
64
+ StaticFiles(directory=str(_STATIC)),
65
+ name="assets",
66
+ )
@@ -0,0 +1,243 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>CSV → JSON</title>
7
+ <style>
8
+ :root {
9
+ --bg: #0f1419;
10
+ --panel: #1a2332;
11
+ --border: #2d3a4f;
12
+ --text: #e7ecf3;
13
+ --muted: #8b9cb3;
14
+ --accent: #5b9fd4;
15
+ --error: #e06c75;
16
+ --font: "SF Pro Text", "Segoe UI", system-ui, sans-serif;
17
+ --mono: "SF Mono", "Consolas", "Liberation Mono", monospace;
18
+ }
19
+ * {
20
+ box-sizing: border-box;
21
+ }
22
+ body {
23
+ margin: 0;
24
+ min-height: 100vh;
25
+ background: var(--bg);
26
+ color: var(--text);
27
+ font-family: var(--font);
28
+ display: flex;
29
+ flex-direction: column;
30
+ }
31
+ header {
32
+ padding: 0.75rem 1.25rem;
33
+ border-bottom: 1px solid var(--border);
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: space-between;
37
+ gap: 1rem;
38
+ flex-wrap: wrap;
39
+ }
40
+ h1 {
41
+ margin: 0;
42
+ font-size: 1.1rem;
43
+ font-weight: 600;
44
+ letter-spacing: -0.02em;
45
+ }
46
+ .toolbar {
47
+ display: flex;
48
+ align-items: center;
49
+ gap: 0.75rem;
50
+ flex-wrap: wrap;
51
+ }
52
+ label {
53
+ font-size: 0.8rem;
54
+ color: var(--muted);
55
+ display: flex;
56
+ align-items: center;
57
+ gap: 0.35rem;
58
+ }
59
+ input[type="number"] {
60
+ width: 3.5rem;
61
+ padding: 0.35rem 0.5rem;
62
+ border: 1px solid var(--border);
63
+ border-radius: 6px;
64
+ background: var(--panel);
65
+ color: var(--text);
66
+ font-family: var(--mono);
67
+ font-size: 0.85rem;
68
+ }
69
+ button {
70
+ font-family: var(--font);
71
+ font-size: 0.875rem;
72
+ font-weight: 500;
73
+ padding: 0.45rem 1rem;
74
+ border: none;
75
+ border-radius: 8px;
76
+ background: var(--accent);
77
+ color: #0a0e14;
78
+ cursor: pointer;
79
+ }
80
+ button:hover {
81
+ filter: brightness(1.08);
82
+ }
83
+ button:disabled {
84
+ opacity: 0.5;
85
+ cursor: not-allowed;
86
+ }
87
+ main {
88
+ flex: 1;
89
+ display: grid;
90
+ grid-template-columns: 1fr 1fr;
91
+ gap: 0;
92
+ min-height: 0;
93
+ }
94
+ @media (max-width: 800px) {
95
+ main {
96
+ grid-template-columns: 1fr;
97
+ grid-template-rows: 1fr 1fr;
98
+ }
99
+ }
100
+ .pane {
101
+ display: flex;
102
+ flex-direction: column;
103
+ min-height: 0;
104
+ border-right: 1px solid var(--border);
105
+ }
106
+ .pane:last-child {
107
+ border-right: none;
108
+ }
109
+ @media (max-width: 800px) {
110
+ .pane {
111
+ border-right: none;
112
+ border-bottom: 1px solid var(--border);
113
+ }
114
+ .pane:last-child {
115
+ border-bottom: none;
116
+ }
117
+ }
118
+ .pane-header {
119
+ padding: 0.5rem 1rem;
120
+ font-size: 0.75rem;
121
+ font-weight: 600;
122
+ text-transform: uppercase;
123
+ letter-spacing: 0.06em;
124
+ color: var(--muted);
125
+ background: var(--panel);
126
+ border-bottom: 1px solid var(--border);
127
+ }
128
+ textarea {
129
+ flex: 1;
130
+ width: 100%;
131
+ margin: 0;
132
+ padding: 1rem;
133
+ border: none;
134
+ resize: none;
135
+ font-family: var(--mono);
136
+ font-size: 0.8125rem;
137
+ line-height: 1.5;
138
+ background: var(--bg);
139
+ color: var(--text);
140
+ tab-size: 2;
141
+ }
142
+ textarea:focus {
143
+ outline: 2px solid var(--accent);
144
+ outline-offset: -2px;
145
+ }
146
+ #out {
147
+ background: #0c1016;
148
+ }
149
+ .status {
150
+ padding: 0.35rem 1rem;
151
+ font-size: 0.8rem;
152
+ min-height: 1.75rem;
153
+ border-top: 1px solid var(--border);
154
+ color: var(--muted);
155
+ }
156
+ .status.error {
157
+ color: var(--error);
158
+ }
159
+ </style>
160
+ </head>
161
+ <body>
162
+ <header>
163
+ <h1>CSV → JSON</h1>
164
+ <div class="toolbar">
165
+ <label
166
+ >Indent
167
+ <input id="indent" type="number" min="0" max="8" value="2"
168
+ /></label>
169
+ <button type="button" id="convert">Convert</button>
170
+ </div>
171
+ </header>
172
+ <main>
173
+ <section class="pane">
174
+ <div class="pane-header">CSV</div>
175
+ <textarea
176
+ id="csv"
177
+ spellcheck="false"
178
+ placeholder="Paste CSV here…"
179
+ ></textarea>
180
+ </section>
181
+ <section class="pane">
182
+ <div class="pane-header">JSON</div>
183
+ <textarea id="out" spellcheck="false" readonly placeholder="…"></textarea>
184
+ </section>
185
+ </main>
186
+ <div class="status" id="status"></div>
187
+ <script>
188
+ const csvEl = document.getElementById("csv");
189
+ const outEl = document.getElementById("out");
190
+ const statusEl = document.getElementById("status");
191
+ const indentEl = document.getElementById("indent");
192
+ const btn = document.getElementById("convert");
193
+
194
+ let debounceTimer;
195
+
196
+ function setStatus(msg, isError) {
197
+ statusEl.textContent = msg || "";
198
+ statusEl.classList.toggle("error", !!isError);
199
+ }
200
+
201
+ async function convert() {
202
+ const indent = parseInt(indentEl.value, 10);
203
+ const indentVal = Number.isFinite(indent) ? indent : 2;
204
+ btn.disabled = true;
205
+ setStatus("Converting…");
206
+ outEl.value = "";
207
+ try {
208
+ const res = await fetch("/api/convert", {
209
+ method: "POST",
210
+ headers: { "Content-Type": "application/json" },
211
+ body: JSON.stringify({ csv: csvEl.value, indent: indentVal }),
212
+ });
213
+ const data = await res.json().catch(() => ({}));
214
+ if (!res.ok) {
215
+ const detail =
216
+ typeof data.detail === "string"
217
+ ? data.detail
218
+ : JSON.stringify(data.detail || data);
219
+ throw new Error(detail || res.statusText);
220
+ }
221
+ outEl.value = data.output || "";
222
+ setStatus("Done.");
223
+ } catch (e) {
224
+ setStatus(e.message || String(e), true);
225
+ } finally {
226
+ btn.disabled = false;
227
+ }
228
+ }
229
+
230
+ btn.addEventListener("click", convert);
231
+ csvEl.addEventListener("keydown", (e) => {
232
+ if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
233
+ e.preventDefault();
234
+ convert();
235
+ }
236
+ });
237
+ csvEl.addEventListener("input", () => {
238
+ clearTimeout(debounceTimer);
239
+ debounceTimer = setTimeout(convert, 400);
240
+ });
241
+ </script>
242
+ </body>
243
+ </html>
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: csvtojsonify
3
+ Version: 2.0.0
4
+ Summary: Convert CSV text to JSON — library, CLI, and optional web UI
5
+ Author-email: Sriram Sreedhar <sriramsreedhar003@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://pypi.org/project/csvtojsonify/
8
+ Project-URL: Repository, https://github.com/sriramsreedhar/csvtojsonify
9
+ Keywords: csv,json,convert
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Provides-Extra: web
21
+ Requires-Dist: fastapi>=0.100.0; extra == "web"
22
+ Requires-Dist: uvicorn[standard]>=0.22.0; extra == "web"
23
+ Dynamic: license-file
24
+
25
+ # csvtojsonify
26
+
27
+ Convert CSV to JSON as a Python library, CLI, or browser UI.
28
+
29
+ ## Install from PyPI
30
+
31
+ ```bash
32
+ pip install csvtojsonify
33
+ ```
34
+
35
+ Web UI (FastAPI + Uvicorn):
36
+
37
+ ```bash
38
+ pip install csvtojsonify[web]
39
+ ```
40
+
41
+ ## Install from source
42
+
43
+ ```bash
44
+ pip install .
45
+ pip install ".[web]"
46
+ ```
47
+
48
+ ## Library
49
+
50
+ ```python
51
+ from csvtojsonify import csv_to_json
52
+
53
+ json_str = csv_to_json("name,age\nAlice,30")
54
+ ```
55
+
56
+ ## CLI
57
+
58
+ ```bash
59
+ csvtojsonify < input.csv > out.json
60
+ csvtojsonify path/to/file.csv
61
+ csvtojsonify --compact < data.csv
62
+ ```
63
+
64
+ ## Web UI
65
+
66
+ ```bash
67
+ csvtojsonify-web
68
+ ```
69
+
70
+ Open http://127.0.0.1:8765 — paste CSV on the left, JSON appears on the right.
71
+
72
+ ## Publishing to PyPI (maintainers)
73
+
74
+ 1. [Create a PyPI account](https://pypi.org/account/register/) and [API token](https://pypi.org/manage/account/token/) (scope: entire account or this project only).
75
+ 2. Install build tools: `pip install build twine`
76
+ 3. Bump the `version` in `pyproject.toml` (and `__version__` in `src/csvtojsonify/__init__.py`) to a **new** number; PyPI rejects re-uploading the same version.
77
+ 5. Build artifacts:
78
+
79
+ ```bash
80
+ python -m build
81
+ ```
82
+
83
+ 6. Upload to the **test** index first (recommended):
84
+
85
+ ```bash
86
+ python -m twine upload --repository testpypi dist/*
87
+ ```
88
+
89
+ Verify: `pip install -i https://test.pypi.org/simple/ csvtojsonify`
90
+
91
+ 7. Upload to **production** PyPI:
92
+
93
+ ```bash
94
+ python -m twine upload dist/*
95
+ ```
96
+
97
+ Configure credentials via `~/.pypirc` or environment variables `TWINE_USERNAME=__token__` and `TWINE_PASSWORD=pypi-...`.
98
+
99
+ After the first release, users install with `pip install csvtojsonify`.
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/csvtojsonify/__init__.py
5
+ src/csvtojsonify/cli.py
6
+ src/csvtojsonify/core.py
7
+ src/csvtojsonify.egg-info/PKG-INFO
8
+ src/csvtojsonify.egg-info/SOURCES.txt
9
+ src/csvtojsonify.egg-info/dependency_links.txt
10
+ src/csvtojsonify.egg-info/entry_points.txt
11
+ src/csvtojsonify.egg-info/requires.txt
12
+ src/csvtojsonify.egg-info/top_level.txt
13
+ src/csvtojsonify/web/__init__.py
14
+ src/csvtojsonify/web/app.py
15
+ src/csvtojsonify/web/static/index.html
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ csvtojsonify = csvtojsonify.cli:main
3
+ csvtojsonify-web = csvtojsonify.cli:main_web
@@ -0,0 +1,4 @@
1
+
2
+ [web]
3
+ fastapi>=0.100.0
4
+ uvicorn[standard]>=0.22.0
@@ -1,5 +0,0 @@
1
- # MANIFEST.in
2
- include csvtojsonify.py
3
- include README.md
4
- #include csvtojsonify/*
5
- recursive-include csvtojsonify *.py
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: csvtojsonify
3
- Version: 1.3.0
4
- Summary: A tool to convert CSV files to JSON.
5
- Home-page: https://github.com/sriramsreedhar/csvtojsonify
6
- Author: Sriram Sreedhar
7
- Author-email: sriramsreedhar003@gmail.com
8
- Requires-Python: >=3.9.6
9
- Description-Content-Type: text/markdown
10
-
11
- # csvtojsonify
12
-
13
- A simple tool to convert CSV files to JSON format.
14
-
15
- ## Usage
16
-
17
- Simply run `csvtojsonify` it will prompt you to enter input CSV file with .csv file extension and output JSON file with .json file extension.
18
-
19
- ##Sample Run
20
- (venv-3.12) % python3 csvtojsonify.py
21
- Enter the input CSV file name: somefile.csv
22
- Enter the output JSON file name: results.json
23
- Conversion successful! The new JSON file is results.json
24
- (venv-3.12) %
@@ -1,14 +0,0 @@
1
- # csvtojsonify
2
-
3
- A simple tool to convert CSV files to JSON format.
4
-
5
- ## Usage
6
-
7
- Simply run `csvtojsonify` it will prompt you to enter input CSV file with .csv file extension and output JSON file with .json file extension.
8
-
9
- ##Sample Run
10
- (venv-3.12) % python3 csvtojsonify.py
11
- Enter the input CSV file name: somefile.csv
12
- Enter the output JSON file name: results.json
13
- Conversion successful! The new JSON file is results.json
14
- (venv-3.12) %
File without changes
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: csvtojsonify
3
- Version: 1.3.0
4
- Summary: A tool to convert CSV files to JSON.
5
- Home-page: https://github.com/sriramsreedhar/csvtojsonify
6
- Author: Sriram Sreedhar
7
- Author-email: sriramsreedhar003@gmail.com
8
- Requires-Python: >=3.9.6
9
- Description-Content-Type: text/markdown
10
-
11
- # csvtojsonify
12
-
13
- A simple tool to convert CSV files to JSON format.
14
-
15
- ## Usage
16
-
17
- Simply run `csvtojsonify` it will prompt you to enter input CSV file with .csv file extension and output JSON file with .json file extension.
18
-
19
- ##Sample Run
20
- (venv-3.12) % python3 csvtojsonify.py
21
- Enter the input CSV file name: somefile.csv
22
- Enter the output JSON file name: results.json
23
- Conversion successful! The new JSON file is results.json
24
- (venv-3.12) %
@@ -1,10 +0,0 @@
1
- MANIFEST.in
2
- README.md
3
- csvtojsonify.py
4
- setup.py
5
- csvtojsonify/__init__.py
6
- csvtojsonify.egg-info/PKG-INFO
7
- csvtojsonify.egg-info/SOURCES.txt
8
- csvtojsonify.egg-info/dependency_links.txt
9
- csvtojsonify.egg-info/entry_points.txt
10
- csvtojsonify.egg-info/top_level.txt
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- csvtojsonify = csvtojsonify.csvtojsonify:main
@@ -1,35 +0,0 @@
1
- # csvtojsonify.py
2
-
3
- import csv
4
- import json
5
-
6
- def convert_csv_to_json(csv_file, json_file):
7
- with open(csv_file, 'r') as csvfile:
8
- reader = csv.reader(csvfile)
9
- data = list(reader)
10
-
11
- with open(json_file, 'w') as jsonfile:
12
- json.dump(data, jsonfile)
13
-
14
- def main():
15
- # Get the input and output file names from the user
16
- csv_file = input("Enter the input CSV file name: ")
17
- json_file = input("Enter the output JSON file name: ")
18
-
19
- # Check if input file name ends with ".csv"
20
- if not csv_file.endswith(".csv"):
21
- print("Error: Input file name must end with '.csv'")
22
- return
23
-
24
- # Check if output file name ends with ".json"
25
- if not json_file.endswith(".json"):
26
- print("Error: Output file name must end with '.json'")
27
- return
28
-
29
- # Call the conversion function
30
- convert_csv_to_json(csv_file, json_file)
31
-
32
- print("Conversion successful! The new JSON file is", json_file)
33
-
34
- if __name__ == "__main__":
35
- main()
@@ -1,20 +0,0 @@
1
- from setuptools import setup
2
-
3
- setup(
4
- name='csvtojsonify',
5
- version='1.3.0',
6
- packages=['csvtojsonify'],
7
- entry_points={
8
- 'console_scripts': [
9
- 'csvtojsonify=csvtojsonify.csvtojsonify:main',
10
- ],
11
- },
12
- install_requires=[],
13
- python_requires='>=3.9.6',
14
- author='Sriram Sreedhar',
15
- author_email='sriramsreedhar003@gmail.com',
16
- description='A tool to convert CSV files to JSON.',
17
- long_description=open('README.md').read(),
18
- long_description_content_type='text/markdown',
19
- url='https://github.com/sriramsreedhar/csvtojsonify',
20
- )
File without changes