spio 0.0.6.post12__tar.gz → 0.0.7__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.
Potentially problematic release.
This version of spio might be problematic. Click here for more details.
- spio-0.0.7/PKG-INFO +286 -0
- spio-0.0.7/README.md +266 -0
- spio-0.0.6.post12/PKG-INFO +0 -157
- spio-0.0.6.post12/README.md +0 -137
- {spio-0.0.6.post12 → spio-0.0.7}/LICENSE.md +0 -0
- {spio-0.0.6.post12 → spio-0.0.7}/pyproject.toml +0 -0
- {spio-0.0.6.post12 → spio-0.0.7}/src/marvin/__init__.py +0 -0
- {spio-0.0.6.post12 → spio-0.0.7}/src/marvin/tools/default_config.ini +0 -0
- {spio-0.0.6.post12 → spio-0.0.7}/src/marvin/tools/spio.py +0 -0
spio-0.0.7/PKG-INFO
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: spio
|
|
3
|
+
Version: 0.0.7
|
|
4
|
+
Summary: Magical Marvin SharePoint Library
|
|
5
|
+
Author: Roeland Maes
|
|
6
|
+
Author-email: roeland.maes@vito.be
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Provides-Extra: full
|
|
13
|
+
Provides-Extra: pandas
|
|
14
|
+
Provides-Extra: pandas-parquet
|
|
15
|
+
Provides-Extra: pandas-xlsx
|
|
16
|
+
Requires-Dist: Office365-REST-Python-Client (>=2.3,<3.0)
|
|
17
|
+
Requires-Dist: msal_extensions (>=0.3,<0.4)
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Spio
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
|
|
25
|
+
Spio is a Python package that provides functionalities for reading and writing data to a SharePoint.
|
|
26
|
+
It can also handle various types of spatial and non-spatial data formats such as GeoTIFF, GeoPackage, NetCDF, CSV, Excel, and more.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
To install the package, you can use the following command:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install spio
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If you want to install the package with all the dependencies, you can use the following command:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install spio[full]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Building from Source
|
|
43
|
+
|
|
44
|
+
To build the package from source you can use the following commands:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
48
|
+
cd sharepoint_tools
|
|
49
|
+
conda create -f conda_env.yml
|
|
50
|
+
conda activate spio
|
|
51
|
+
poetry install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
Before using the package, you need to configure the settings to match your environment.
|
|
57
|
+
The configuration is managed through a `settings` module which should include all the necessary configurations.
|
|
58
|
+
|
|
59
|
+
### **Settings Configuration**:
|
|
60
|
+
Ensure you have a `settings` file (e.g., `.secrets.yaml` or `settings.yaml`) that provides the necessary configuration options. Example:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from dynaconf import Dynaconf
|
|
64
|
+
|
|
65
|
+
settings = Dynaconf(
|
|
66
|
+
settings_files=['settings.yaml', '.secrets.yaml']
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The settings file should include the following configurations:
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
user_account: your.name@vito.be
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### **Initialize Spio with Settings**:
|
|
77
|
+
You need to initialize Spio with your settings before using any functionalities.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from config import settings
|
|
81
|
+
from marvin.tools import spio
|
|
82
|
+
|
|
83
|
+
spio.init_spio(settings)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Usage
|
|
87
|
+
|
|
88
|
+
Here are some example usages of the package:
|
|
89
|
+
|
|
90
|
+
### Reading Data
|
|
91
|
+
|
|
92
|
+
- **Read GeoTIFF using Rasterio**:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from marvin.tools.spio import SPIO
|
|
96
|
+
import rasterio
|
|
97
|
+
|
|
98
|
+
geotiff_file = SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geotiff.tiff')
|
|
99
|
+
with rasterio.open(geotiff_file.copy_bytes_io()) as src:
|
|
100
|
+
# Read the dataset's metadata
|
|
101
|
+
print("Metadata:", src.meta)
|
|
102
|
+
print("CRS:", src.crs)
|
|
103
|
+
print("Bounds:", src.bounds)
|
|
104
|
+
data = src.read()
|
|
105
|
+
print("data: ", data.shape)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Read GeoTIFF using GDAL**:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from marvin.tools.spio import SPIO
|
|
112
|
+
from osgeo import gdal
|
|
113
|
+
|
|
114
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geotiff.tiff') as spio:
|
|
115
|
+
dataset = gdal.Open(spio.copy_file())
|
|
116
|
+
band = dataset.GetRasterBand(1)
|
|
117
|
+
data = band.ReadAsArray()
|
|
118
|
+
print("data: ", data.shape)
|
|
119
|
+
# Close the dataset
|
|
120
|
+
del dataset
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- **Read GeoPackage**:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from marvin.tools.spio import SPIO
|
|
127
|
+
import geopandas as gpd
|
|
128
|
+
|
|
129
|
+
gdf = gpd.read_file(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geopackage.gpkg'))
|
|
130
|
+
print("gdf: ", gdf)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- **Read NetCDF (h5netcdf)**:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from marvin.tools.spio import SPIO
|
|
137
|
+
import xarray as xr
|
|
138
|
+
|
|
139
|
+
ds = xr.load_dataset(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/netcdf.nc')) # use engine='h5netcdf' if not detected correctly
|
|
140
|
+
print("ds: ", ds)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- **Read NetCDF (netcdf4)**:
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from marvin.tools.spio import SPIO
|
|
147
|
+
import xarray as xr
|
|
148
|
+
|
|
149
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/netcdf.nc') as spio:
|
|
150
|
+
ds = xr.load_dataset(spio.copy_file(), engine='netcdf4')
|
|
151
|
+
print("ds: ", ds)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- **Read GRIB**:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from marvin.tools.spio import SPIO
|
|
158
|
+
import xarray as xr
|
|
159
|
+
|
|
160
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/grib.grb') as spio:
|
|
161
|
+
grb_ds = xr.load_dataset(spio.copy_file()) # engine='cfgrib'
|
|
162
|
+
print("grb_ds: ", grb_ds)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- **Read Parquet**:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from marvin.tools.spio import SPIO
|
|
169
|
+
import pandas as pd
|
|
170
|
+
|
|
171
|
+
df = pd.read_parquet(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.parquet'))
|
|
172
|
+
print("df: ", df)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- **Read CSV**:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from marvin.tools.spio import SPIO
|
|
179
|
+
import pandas as pd
|
|
180
|
+
|
|
181
|
+
df = pd.read_csv(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.csv'))
|
|
182
|
+
print(f"df: , df")
|
|
183
|
+
|
|
184
|
+
# read first lines
|
|
185
|
+
df_top = pd.read_csv(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.csv', read_chunks=SPIO.DEFAULT_CHUNK_SIZE), sep=';', nrows=10)
|
|
186
|
+
print(f"df_top: , df_top")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
- **Read Excel**:
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from marvin.tools.spio import SPIO
|
|
193
|
+
import pandas as pd
|
|
194
|
+
|
|
195
|
+
df = pd.read_excel(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.xlsx'))
|
|
196
|
+
print("df: ", df)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
### Writing Data
|
|
201
|
+
|
|
202
|
+
- **Write CSV**:
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from marvin.tools.spio import SPIO
|
|
206
|
+
import pandas as pd
|
|
207
|
+
|
|
208
|
+
df = pd.read_csv('path/to/your/data.csv')
|
|
209
|
+
df.to_csv(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.csv'))
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
- **Write Excel**:
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
from marvin.tools.spio import SPIO
|
|
216
|
+
import pandas as pd
|
|
217
|
+
|
|
218
|
+
df = pd.read_csv('path/to/your/data.csv')
|
|
219
|
+
df.to_excel(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.xlsx'), engine='xlsxwriter')
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
- **Write Text**:
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from marvin.tools.spio import SPIO
|
|
226
|
+
|
|
227
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.txt') as spio:
|
|
228
|
+
spio.write_lines(['Hello, SPIO!'])
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
- **Write GeoTiff**:
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
from marvin.tools.spio import SPIO
|
|
236
|
+
import rasterio
|
|
237
|
+
|
|
238
|
+
with rasterio.open('path/to/your/map.tiff') as src:
|
|
239
|
+
data = src.read()[0]
|
|
240
|
+
profile = src.profile
|
|
241
|
+
|
|
242
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/map.tiff') as spio: # rasterio will not flush or close the SPIO file, so we need to do it ourselves
|
|
243
|
+
with rasterio.open(spio, 'w', **profile) as dst:
|
|
244
|
+
dst.write(data, 1)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
- **Write GeoPackage Fiona**:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from marvin.tools.spio import SPIO
|
|
252
|
+
import geopandas as gpd
|
|
253
|
+
|
|
254
|
+
gdf = gpd.read_file('path/to/your/geopackage.gpkg')
|
|
255
|
+
|
|
256
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geopackage.gpkg') as spio: # fiona will not flush or close the IO-object, so we need to do it ourselves
|
|
257
|
+
gdf.to_file(spio, layer='mylayer', driver='GPKG', engine='fiona')
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- **Write GeoPackage Fiona**:
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
from marvin.tools.spio import SPIO
|
|
264
|
+
import geopandas as gpd
|
|
265
|
+
|
|
266
|
+
gdf = gpd.read_file('path/to/your/geopackage.gpkg')
|
|
267
|
+
|
|
268
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geopackage.gpkg') as spio: # pyogrio will not flush the IO-object
|
|
269
|
+
gdf.to_file(spio.io_delegate(), layer='mylayer', driver='GPKG', engine='pyogrio') # pyogrio can only write to a real BytesIO object.
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Additional Functionalities
|
|
273
|
+
|
|
274
|
+
Spio also provides additional functions to handle different data formats and processes.
|
|
275
|
+
You can explore these in the https://git.vito.be/projects/MARVIN/repos/sharepoint_tools/browse/test/tst_spio.py.
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
## Contributing
|
|
279
|
+
|
|
280
|
+
If you want to contribute to spio, please follow the standard contributing guidelines and push your changes to a new branch in
|
|
281
|
+
https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
This project is licensed under the MIT License - see the LICENSE.md file for details.
|
|
286
|
+
|
spio-0.0.7/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
|
|
2
|
+
# Spio
|
|
3
|
+
|
|
4
|
+
## Description
|
|
5
|
+
|
|
6
|
+
Spio is a Python package that provides functionalities for reading and writing data to a SharePoint.
|
|
7
|
+
It can also handle various types of spatial and non-spatial data formats such as GeoTIFF, GeoPackage, NetCDF, CSV, Excel, and more.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
To install the package, you can use the following command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install spio
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
If you want to install the package with all the dependencies, you can use the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install spio[full]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Building from Source
|
|
24
|
+
|
|
25
|
+
To build the package from source you can use the following commands:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
29
|
+
cd sharepoint_tools
|
|
30
|
+
conda create -f conda_env.yml
|
|
31
|
+
conda activate spio
|
|
32
|
+
poetry install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
Before using the package, you need to configure the settings to match your environment.
|
|
38
|
+
The configuration is managed through a `settings` module which should include all the necessary configurations.
|
|
39
|
+
|
|
40
|
+
### **Settings Configuration**:
|
|
41
|
+
Ensure you have a `settings` file (e.g., `.secrets.yaml` or `settings.yaml`) that provides the necessary configuration options. Example:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from dynaconf import Dynaconf
|
|
45
|
+
|
|
46
|
+
settings = Dynaconf(
|
|
47
|
+
settings_files=['settings.yaml', '.secrets.yaml']
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The settings file should include the following configurations:
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
user_account: your.name@vito.be
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### **Initialize Spio with Settings**:
|
|
58
|
+
You need to initialize Spio with your settings before using any functionalities.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from config import settings
|
|
62
|
+
from marvin.tools import spio
|
|
63
|
+
|
|
64
|
+
spio.init_spio(settings)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
Here are some example usages of the package:
|
|
70
|
+
|
|
71
|
+
### Reading Data
|
|
72
|
+
|
|
73
|
+
- **Read GeoTIFF using Rasterio**:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from marvin.tools.spio import SPIO
|
|
77
|
+
import rasterio
|
|
78
|
+
|
|
79
|
+
geotiff_file = SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geotiff.tiff')
|
|
80
|
+
with rasterio.open(geotiff_file.copy_bytes_io()) as src:
|
|
81
|
+
# Read the dataset's metadata
|
|
82
|
+
print("Metadata:", src.meta)
|
|
83
|
+
print("CRS:", src.crs)
|
|
84
|
+
print("Bounds:", src.bounds)
|
|
85
|
+
data = src.read()
|
|
86
|
+
print("data: ", data.shape)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- **Read GeoTIFF using GDAL**:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from marvin.tools.spio import SPIO
|
|
93
|
+
from osgeo import gdal
|
|
94
|
+
|
|
95
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geotiff.tiff') as spio:
|
|
96
|
+
dataset = gdal.Open(spio.copy_file())
|
|
97
|
+
band = dataset.GetRasterBand(1)
|
|
98
|
+
data = band.ReadAsArray()
|
|
99
|
+
print("data: ", data.shape)
|
|
100
|
+
# Close the dataset
|
|
101
|
+
del dataset
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- **Read GeoPackage**:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from marvin.tools.spio import SPIO
|
|
108
|
+
import geopandas as gpd
|
|
109
|
+
|
|
110
|
+
gdf = gpd.read_file(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geopackage.gpkg'))
|
|
111
|
+
print("gdf: ", gdf)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
- **Read NetCDF (h5netcdf)**:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from marvin.tools.spio import SPIO
|
|
118
|
+
import xarray as xr
|
|
119
|
+
|
|
120
|
+
ds = xr.load_dataset(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/netcdf.nc')) # use engine='h5netcdf' if not detected correctly
|
|
121
|
+
print("ds: ", ds)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- **Read NetCDF (netcdf4)**:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from marvin.tools.spio import SPIO
|
|
128
|
+
import xarray as xr
|
|
129
|
+
|
|
130
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/netcdf.nc') as spio:
|
|
131
|
+
ds = xr.load_dataset(spio.copy_file(), engine='netcdf4')
|
|
132
|
+
print("ds: ", ds)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- **Read GRIB**:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from marvin.tools.spio import SPIO
|
|
139
|
+
import xarray as xr
|
|
140
|
+
|
|
141
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/grib.grb') as spio:
|
|
142
|
+
grb_ds = xr.load_dataset(spio.copy_file()) # engine='cfgrib'
|
|
143
|
+
print("grb_ds: ", grb_ds)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- **Read Parquet**:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from marvin.tools.spio import SPIO
|
|
150
|
+
import pandas as pd
|
|
151
|
+
|
|
152
|
+
df = pd.read_parquet(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.parquet'))
|
|
153
|
+
print("df: ", df)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- **Read CSV**:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from marvin.tools.spio import SPIO
|
|
160
|
+
import pandas as pd
|
|
161
|
+
|
|
162
|
+
df = pd.read_csv(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.csv'))
|
|
163
|
+
print(f"df: , df")
|
|
164
|
+
|
|
165
|
+
# read first lines
|
|
166
|
+
df_top = pd.read_csv(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.csv', read_chunks=SPIO.DEFAULT_CHUNK_SIZE), sep=';', nrows=10)
|
|
167
|
+
print(f"df_top: , df_top")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- **Read Excel**:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from marvin.tools.spio import SPIO
|
|
174
|
+
import pandas as pd
|
|
175
|
+
|
|
176
|
+
df = pd.read_excel(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.xlsx'))
|
|
177
|
+
print("df: ", df)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
### Writing Data
|
|
182
|
+
|
|
183
|
+
- **Write CSV**:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from marvin.tools.spio import SPIO
|
|
187
|
+
import pandas as pd
|
|
188
|
+
|
|
189
|
+
df = pd.read_csv('path/to/your/data.csv')
|
|
190
|
+
df.to_csv(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.csv'))
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- **Write Excel**:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
from marvin.tools.spio import SPIO
|
|
197
|
+
import pandas as pd
|
|
198
|
+
|
|
199
|
+
df = pd.read_csv('path/to/your/data.csv')
|
|
200
|
+
df.to_excel(SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.xlsx'), engine='xlsxwriter')
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- **Write Text**:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from marvin.tools.spio import SPIO
|
|
207
|
+
|
|
208
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/data.txt') as spio:
|
|
209
|
+
spio.write_lines(['Hello, SPIO!'])
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
- **Write GeoTiff**:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from marvin.tools.spio import SPIO
|
|
217
|
+
import rasterio
|
|
218
|
+
|
|
219
|
+
with rasterio.open('path/to/your/map.tiff') as src:
|
|
220
|
+
data = src.read()[0]
|
|
221
|
+
profile = src.profile
|
|
222
|
+
|
|
223
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/map.tiff') as spio: # rasterio will not flush or close the SPIO file, so we need to do it ourselves
|
|
224
|
+
with rasterio.open(spio, 'w', **profile) as dst:
|
|
225
|
+
dst.write(data, 1)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
- **Write GeoPackage Fiona**:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from marvin.tools.spio import SPIO
|
|
233
|
+
import geopandas as gpd
|
|
234
|
+
|
|
235
|
+
gdf = gpd.read_file('path/to/your/geopackage.gpkg')
|
|
236
|
+
|
|
237
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geopackage.gpkg') as spio: # fiona will not flush or close the IO-object, so we need to do it ourselves
|
|
238
|
+
gdf.to_file(spio, layer='mylayer', driver='GPKG', engine='fiona')
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- **Write GeoPackage Fiona**:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
from marvin.tools.spio import SPIO
|
|
245
|
+
import geopandas as gpd
|
|
246
|
+
|
|
247
|
+
gdf = gpd.read_file('path/to/your/geopackage.gpkg')
|
|
248
|
+
|
|
249
|
+
with SPIO('https://yourdomain.sharepoint.com/:i:/r/sites/your-site/path/to/your/geopackage.gpkg') as spio: # pyogrio will not flush the IO-object
|
|
250
|
+
gdf.to_file(spio.io_delegate(), layer='mylayer', driver='GPKG', engine='pyogrio') # pyogrio can only write to a real BytesIO object.
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Additional Functionalities
|
|
254
|
+
|
|
255
|
+
Spio also provides additional functions to handle different data formats and processes.
|
|
256
|
+
You can explore these in the https://git.vito.be/projects/MARVIN/repos/sharepoint_tools/browse/test/tst_spio.py.
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
## Contributing
|
|
260
|
+
|
|
261
|
+
If you want to contribute to spio, please follow the standard contributing guidelines and push your changes to a new branch in
|
|
262
|
+
https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
This project is licensed under the MIT License - see the LICENSE.md file for details.
|
spio-0.0.6.post12/PKG-INFO
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: spio
|
|
3
|
-
Version: 0.0.6.post12
|
|
4
|
-
Summary: Magical Marvin SharePoint Library
|
|
5
|
-
Author: Roeland Maes
|
|
6
|
-
Author-email: roeland.maes@vito.be
|
|
7
|
-
Requires-Python: >=3.10,<4.0
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
-
Provides-Extra: full
|
|
13
|
-
Provides-Extra: pandas
|
|
14
|
-
Provides-Extra: pandas-parquet
|
|
15
|
-
Provides-Extra: pandas-xlsx
|
|
16
|
-
Requires-Dist: Office365-REST-Python-Client (>=2.3,<3.0)
|
|
17
|
-
Requires-Dist: msal_extensions (>=0.3,<0.4)
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Spio
|
|
22
|
-
|
|
23
|
-
## Description
|
|
24
|
-
|
|
25
|
-
Spio is a Python package that provides functionalities for reading and writing data to a SharePoint.
|
|
26
|
-
It can also handle various types of spatial and non-spatial data formats such as GeoTIFF, GeoPackage, NetCDF, CSV, Excel, and more.
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
To install the package, you can use the following command:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
pip config set global.extra-index-url https://repo.vito.be/artifactory/api/pypi/marvin-projects-pypi-local/simple
|
|
34
|
-
pip install spio
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
If you want to install the package with all the dependencies, you can use the following command:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
pip install spio[full]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Building from Source
|
|
44
|
-
|
|
45
|
-
To build the package from source you can use the following commands:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
git clone https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
49
|
-
cd sharepoint_tools
|
|
50
|
-
conda create -f conda_env.yml
|
|
51
|
-
conda activate spio
|
|
52
|
-
poetry install
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Configuration
|
|
56
|
-
|
|
57
|
-
Before using the package, you need to configure the settings to match your environment.
|
|
58
|
-
The configuration is managed through a `settings` module which should include all the necessary configurations.
|
|
59
|
-
|
|
60
|
-
### **Settings Configuration**:
|
|
61
|
-
Ensure you have a `settings` file (e.g., `.secrets.yaml` or `settings.yaml`) that provides the necessary configuration options. Example:
|
|
62
|
-
|
|
63
|
-
```python
|
|
64
|
-
from dynaconf import Dynaconf
|
|
65
|
-
|
|
66
|
-
settings = Dynaconf(
|
|
67
|
-
settings_files=['settings.yaml', '.secrets.yaml']
|
|
68
|
-
)
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The settings file should include the following configurations:
|
|
72
|
-
|
|
73
|
-
```yaml
|
|
74
|
-
user_account: your.name@vito.be
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### **Initialize Spio with Settings**:
|
|
78
|
-
You need to initialize Spio with your settings before using any functionalities.
|
|
79
|
-
|
|
80
|
-
```python
|
|
81
|
-
from config import settings
|
|
82
|
-
from marvin.tools import spio
|
|
83
|
-
|
|
84
|
-
spio.init_spio(settings)
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Usage
|
|
88
|
-
|
|
89
|
-
Here are some example usages of the package:
|
|
90
|
-
|
|
91
|
-
### Reading Data
|
|
92
|
-
|
|
93
|
-
- **Read GeoTIFF using Rasterio**:
|
|
94
|
-
|
|
95
|
-
```python
|
|
96
|
-
from marvin.tools.spio import read_geotiff_rasterio
|
|
97
|
-
|
|
98
|
-
geotiff_data = read_geotiff_rasterio('path/to/your/geotiff/file.tif')
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
- **Read GeoPackage**:
|
|
102
|
-
|
|
103
|
-
```python
|
|
104
|
-
from marvin.tools.spio import read_geopackage
|
|
105
|
-
|
|
106
|
-
geopackage_data = read_geopackage('path/to/your/geopackage/file.gpkg')
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
- **Read NetCDF**:
|
|
110
|
-
|
|
111
|
-
```python
|
|
112
|
-
from marvin.tools.spio import read_netcdf
|
|
113
|
-
|
|
114
|
-
netcdf_data = read_netcdf('path/to/your/netcdf/file.nc')
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
- **Read CSV**:
|
|
118
|
-
|
|
119
|
-
```python
|
|
120
|
-
from marvin.tools.spio import read_csv
|
|
121
|
-
|
|
122
|
-
csv_data = read_csv('path/to/your/csv/file.csv')
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Writing Data
|
|
126
|
-
|
|
127
|
-
- **Write CSV**:
|
|
128
|
-
|
|
129
|
-
```python
|
|
130
|
-
from marvin.tools.spio import write_csv
|
|
131
|
-
|
|
132
|
-
write_csv('path/to/your/output/file.csv', csv_data)
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
- **Write Excel**:
|
|
136
|
-
|
|
137
|
-
```python
|
|
138
|
-
from marvin.tools.spio import write_excel
|
|
139
|
-
|
|
140
|
-
write_excel('path/to/your/output/file.xlsx', excel_data)
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Additional Functionalities
|
|
144
|
-
|
|
145
|
-
Spio also provides additional functions to handle different data formats and processes.
|
|
146
|
-
You can explore these in the https://git.vito.be/projects/MARVIN/repos/sharepoint_tools/browse/test/tst_spio.py file for more complex scenarios such as writing to OneDrive, processing NetCDF4 files, and more.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
## Contributing
|
|
150
|
-
|
|
151
|
-
If you want to contribute to spio, please follow the standard contributing guidelines and push your changes to a new branch in
|
|
152
|
-
https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
153
|
-
|
|
154
|
-
## License
|
|
155
|
-
|
|
156
|
-
This project is licensed under the MIT License - see the LICENSE.md file for details.
|
|
157
|
-
|
spio-0.0.6.post12/README.md
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Spio
|
|
3
|
-
|
|
4
|
-
## Description
|
|
5
|
-
|
|
6
|
-
Spio is a Python package that provides functionalities for reading and writing data to a SharePoint.
|
|
7
|
-
It can also handle various types of spatial and non-spatial data formats such as GeoTIFF, GeoPackage, NetCDF, CSV, Excel, and more.
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
To install the package, you can use the following command:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
pip config set global.extra-index-url https://repo.vito.be/artifactory/api/pypi/marvin-projects-pypi-local/simple
|
|
15
|
-
pip install spio
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
If you want to install the package with all the dependencies, you can use the following command:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
pip install spio[full]
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Building from Source
|
|
25
|
-
|
|
26
|
-
To build the package from source you can use the following commands:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
git clone https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
30
|
-
cd sharepoint_tools
|
|
31
|
-
conda create -f conda_env.yml
|
|
32
|
-
conda activate spio
|
|
33
|
-
poetry install
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Configuration
|
|
37
|
-
|
|
38
|
-
Before using the package, you need to configure the settings to match your environment.
|
|
39
|
-
The configuration is managed through a `settings` module which should include all the necessary configurations.
|
|
40
|
-
|
|
41
|
-
### **Settings Configuration**:
|
|
42
|
-
Ensure you have a `settings` file (e.g., `.secrets.yaml` or `settings.yaml`) that provides the necessary configuration options. Example:
|
|
43
|
-
|
|
44
|
-
```python
|
|
45
|
-
from dynaconf import Dynaconf
|
|
46
|
-
|
|
47
|
-
settings = Dynaconf(
|
|
48
|
-
settings_files=['settings.yaml', '.secrets.yaml']
|
|
49
|
-
)
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The settings file should include the following configurations:
|
|
53
|
-
|
|
54
|
-
```yaml
|
|
55
|
-
user_account: your.name@vito.be
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### **Initialize Spio with Settings**:
|
|
59
|
-
You need to initialize Spio with your settings before using any functionalities.
|
|
60
|
-
|
|
61
|
-
```python
|
|
62
|
-
from config import settings
|
|
63
|
-
from marvin.tools import spio
|
|
64
|
-
|
|
65
|
-
spio.init_spio(settings)
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Usage
|
|
69
|
-
|
|
70
|
-
Here are some example usages of the package:
|
|
71
|
-
|
|
72
|
-
### Reading Data
|
|
73
|
-
|
|
74
|
-
- **Read GeoTIFF using Rasterio**:
|
|
75
|
-
|
|
76
|
-
```python
|
|
77
|
-
from marvin.tools.spio import read_geotiff_rasterio
|
|
78
|
-
|
|
79
|
-
geotiff_data = read_geotiff_rasterio('path/to/your/geotiff/file.tif')
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
- **Read GeoPackage**:
|
|
83
|
-
|
|
84
|
-
```python
|
|
85
|
-
from marvin.tools.spio import read_geopackage
|
|
86
|
-
|
|
87
|
-
geopackage_data = read_geopackage('path/to/your/geopackage/file.gpkg')
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- **Read NetCDF**:
|
|
91
|
-
|
|
92
|
-
```python
|
|
93
|
-
from marvin.tools.spio import read_netcdf
|
|
94
|
-
|
|
95
|
-
netcdf_data = read_netcdf('path/to/your/netcdf/file.nc')
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
- **Read CSV**:
|
|
99
|
-
|
|
100
|
-
```python
|
|
101
|
-
from marvin.tools.spio import read_csv
|
|
102
|
-
|
|
103
|
-
csv_data = read_csv('path/to/your/csv/file.csv')
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Writing Data
|
|
107
|
-
|
|
108
|
-
- **Write CSV**:
|
|
109
|
-
|
|
110
|
-
```python
|
|
111
|
-
from marvin.tools.spio import write_csv
|
|
112
|
-
|
|
113
|
-
write_csv('path/to/your/output/file.csv', csv_data)
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
- **Write Excel**:
|
|
117
|
-
|
|
118
|
-
```python
|
|
119
|
-
from marvin.tools.spio import write_excel
|
|
120
|
-
|
|
121
|
-
write_excel('path/to/your/output/file.xlsx', excel_data)
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Additional Functionalities
|
|
125
|
-
|
|
126
|
-
Spio also provides additional functions to handle different data formats and processes.
|
|
127
|
-
You can explore these in the https://git.vito.be/projects/MARVIN/repos/sharepoint_tools/browse/test/tst_spio.py file for more complex scenarios such as writing to OneDrive, processing NetCDF4 files, and more.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
## Contributing
|
|
131
|
-
|
|
132
|
-
If you want to contribute to spio, please follow the standard contributing guidelines and push your changes to a new branch in
|
|
133
|
-
https://git.vito.be/projects/MARVIN/repos/sharepoint_tools
|
|
134
|
-
|
|
135
|
-
## License
|
|
136
|
-
|
|
137
|
-
This project is licensed under the MIT License - see the LICENSE.md file for details.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|