google-data-utils 0.1.0__py3-none-any.whl

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,22 @@
1
+ from .public import (
2
+ google_csv_to_df,
3
+ google_excel_to_df,
4
+ google_sheet_to_df,
5
+ )
6
+
7
+ from .validators import (
8
+ extract_drive_file_id,
9
+ extract_sheet_id,
10
+ is_google_drive_url,
11
+ is_google_sheet_url,
12
+ )
13
+
14
+ __all__ = [
15
+ "google_csv_to_df",
16
+ "google_excel_to_df",
17
+ "google_sheet_to_df",
18
+ "extract_drive_file_id",
19
+ "extract_sheet_id",
20
+ "is_google_drive_url",
21
+ "is_google_sheet_url",
22
+ ]
@@ -0,0 +1,38 @@
1
+ # public.py
2
+
3
+ import pandas as pd
4
+
5
+ from .validators import (
6
+ extract_drive_file_id,
7
+ extract_sheet_id,
8
+ )
9
+
10
+
11
+
12
+ def google_csv_to_df(url, **kwargs):
13
+ file_id = extract_drive_file_id(url)
14
+
15
+ return pd.read_csv(
16
+ f"https://drive.google.com/uc?id={file_id}",
17
+ **kwargs,
18
+ )
19
+
20
+
21
+ def google_excel_to_df(url, **kwargs):
22
+ file_id = extract_drive_file_id(url)
23
+
24
+ return pd.read_excel(
25
+ f"https://drive.google.com/uc?id={file_id}",
26
+ **kwargs,
27
+ )
28
+
29
+
30
+ def google_sheet_to_df(url, **kwargs):
31
+ sheet_id = extract_sheet_id(url)
32
+
33
+ csv_url = (
34
+ f"https://docs.google.com/spreadsheets/d/"
35
+ f"{sheet_id}/export?format=csv"
36
+ )
37
+
38
+ return pd.read_csv(csv_url, **kwargs)
@@ -0,0 +1,87 @@
1
+ # validators.py
2
+
3
+ from urllib.parse import urlparse
4
+ import re
5
+
6
+ class InvalidGoogleUrl(ValueError):
7
+ pass
8
+
9
+
10
+ _DRIVE_FILE_RE = re.compile(
11
+ r"^/file/d/([a-zA-Z0-9_-]+)"
12
+ )
13
+
14
+ _SHEET_RE = re.compile(
15
+ r"^/spreadsheets/d/([a-zA-Z0-9_-]+)"
16
+ )
17
+
18
+ def is_google_drive_url(url: str) -> bool:
19
+ try:
20
+ extract_drive_file_id(url)
21
+ return True
22
+ except InvalidGoogleUrl:
23
+ return False
24
+
25
+
26
+ def is_google_sheet_url(url: str) -> bool:
27
+ try:
28
+ extract_sheet_id(url)
29
+ return True
30
+ except InvalidGoogleUrl:
31
+ return False
32
+
33
+ def extract_drive_file_id(url: str) -> str:
34
+ """
35
+ Accepts:
36
+ https://drive.google.com/file/d/FILE_ID/view
37
+ """
38
+
39
+ parsed = urlparse(url)
40
+
41
+ if parsed.netloc != "drive.google.com":
42
+ raise InvalidGoogleUrl(
43
+ "Expected a drive.google.com URL"
44
+ )
45
+
46
+ match = _DRIVE_FILE_RE.match(parsed.path)
47
+
48
+ if not match:
49
+ raise InvalidGoogleUrl(
50
+ "Could not extract Drive file ID"
51
+ )
52
+
53
+ return match.group(1)
54
+
55
+
56
+ def extract_sheet_id(url: str) -> str:
57
+ """
58
+ Accepts:
59
+ https://docs.google.com/spreadsheets/d/SHEET_ID/edit
60
+ """
61
+
62
+ parsed = urlparse(url)
63
+
64
+ if parsed.netloc != "docs.google.com":
65
+ raise InvalidGoogleUrl(
66
+ "Expected a docs.google.com URL"
67
+ )
68
+
69
+ match = _SHEET_RE.match(parsed.path)
70
+
71
+ if not match:
72
+ raise InvalidGoogleUrl(
73
+ "Could not extract Sheet ID"
74
+ )
75
+
76
+ return match.group(1)
77
+
78
+ def drive_download_url(url: str) -> str:
79
+ file_id = extract_drive_file_id(url)
80
+ return f"https://drive.google.com/uc?id={file_id}"
81
+
82
+ def sheet_csv_url(url: str) -> str:
83
+ sheet_id = extract_sheet_id(url)
84
+ return (
85
+ f"https://docs.google.com/spreadsheets/d/"
86
+ f"{sheet_id}/export?format=csv"
87
+ )
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.4
2
+ Name: google-data-utils
3
+ Version: 0.1.0
4
+ Summary: Load public Google Sheets, CSV, and Excel files into pandas
5
+ Author: Zomi Learner
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ZomiLearner/google-data-utils
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pandas>=1.5
12
+ Requires-Dist: openpyxl>=3.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # google-data-utils
18
+
19
+ Simple utilities for loading public Google Drive CSV files, Excel files, and Google Sheets into pandas DataFrames.
20
+
21
+ > **Note**
22
+ >
23
+ > This package only supports publicly accessible Google Drive files and Google Sheets. Authentication, OAuth, and Google API credentials are not required.
24
+
25
+ ## Features
26
+
27
+ - Read public Google Drive CSV files into a DataFrame
28
+ - Read public Google Drive Excel files into a DataFrame
29
+ - Read public Google Sheets into a DataFrame
30
+ - Validate Google Drive and Google Sheets URLs
31
+ - Extract Google Drive file IDs and Google Sheets IDs
32
+ - No API keys required
33
+ - No OAuth required
34
+ - No Google Cloud setup required
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install google-data-utils
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### Google Drive CSV
45
+
46
+ ```bash
47
+ from google_data_utils import google_csv_to_df
48
+
49
+ df = google_csv_to_df(
50
+ "https://drive.google.com/file/d/FILE_ID/view?usp=sharing"
51
+ )
52
+ ```
53
+
54
+ ### Google Drive Excel
55
+
56
+ ```bash
57
+ from google_data_utils import google_excel_to_df
58
+
59
+ df = google_excel_to_df(
60
+ "https://drive.google.com/file/d/FILE_ID/view?usp=sharing"
61
+ )
62
+ ```
63
+
64
+ ### Google Sheets
65
+
66
+ ```bash
67
+ from google_data_utils import google_sheet_to_df
68
+
69
+ df = google_sheet_to_df(
70
+ "https://docs.google.com/spreadsheets/d/SHEET_ID/edit#gid=0"
71
+ )
72
+ ```
73
+
74
+ ### URL Validation
75
+
76
+ ```bash
77
+ from google_data_utils import (
78
+ is_google_drive_url,
79
+ is_google_sheet_url,
80
+ )
81
+
82
+ is_google_drive_url(
83
+ "https://drive.google.com/file/d/FILE_ID/view"
84
+ )
85
+ # True
86
+
87
+ is_google_sheet_url(
88
+ "https://docs.google.com/spreadsheets/d/SHEET_ID/edit"
89
+ )
90
+ # True
91
+ ```
92
+
93
+ ### Extract IDs
94
+
95
+ ```bash
96
+ from google_data_utils import (
97
+ extract_drive_file_id,
98
+ extract_sheet_id,
99
+ )
100
+
101
+ extract_drive_file_id(
102
+ "https://drive.google.com/file/d/FILE_ID/view"
103
+ )
104
+ # FILE_ID
105
+
106
+ extract_sheet_id(
107
+ "https://docs.google.com/spreadsheets/d/SHEET_ID/edit"
108
+ )
109
+ # SHEET_ID
110
+ ```
111
+
112
+ ### Requirements
113
+
114
+ ```text
115
+ Python 3.8+
116
+ pandas
117
+ openpyxl
118
+ ```
119
+
120
+ ### License
121
+
122
+ ```text
123
+ MIT License
124
+ ```
@@ -0,0 +1,8 @@
1
+ google_data_utils/__init__.py,sha256=tGV5F-zuEx8ABvY7coUsMZHAvB9eymxgyGy7agOAem8,440
2
+ google_data_utils/public.py,sha256=IBn6XtSgGKkS95jq4OsOkw5IUGGGdGxKMw6237uqz5M,755
3
+ google_data_utils/validators.py,sha256=U_SS-XL_klXxDeI8gnf1MwFX2yKF1WfLJLPJQsl2qoE,1890
4
+ google_data_utils-0.1.0.dist-info/licenses/LICENSE,sha256=d6T_o-Df7Rq3BHyQwe9ErjlGSMk5e59UvthELwFInC8,1090
5
+ google_data_utils-0.1.0.dist-info/METADATA,sha256=IXjv3LLCmgovyXCVaG79tcfFk4USSsmw7UcPm7Od6fs,2381
6
+ google_data_utils-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
7
+ google_data_utils-0.1.0.dist-info/top_level.txt,sha256=FvV4kRXkGM0e4MacZ7_PyfWlyE7IAJ57V0MyrH_XI54,18
8
+ google_data_utils-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zomi Learner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ google_data_utils