python-dwca-reader 0.16.0__tar.gz → 0.16.1__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.
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/CHANGES.txt +7 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/PKG-INFO +1 -1
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/helpers.py +1 -1
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/read.py +19 -4
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/test_dwcareader.py +20 -0
- python-dwca-reader-0.16.1/dwca/version.py +1 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/PKG-INFO +1 -1
- python-dwca-reader-0.16.0/dwca/version.py +0 -1
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/AUTHORS +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/LICENSE.txt +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/MANIFEST.in +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/README.rst +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/code_of_conduct.txt +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/__init__.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/darwincore/__init__.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/darwincore/build_dc_terms_list.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/darwincore/terms.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/darwincore/utils.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/descriptors.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/exceptions.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/files.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/minibench.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/rows.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/star_record.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/__init__.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/helpers.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/test_datafile.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/test_descriptors.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/test_rows.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/test/test_star_record.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/vendor.py +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/SOURCES.txt +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/dependency_links.txt +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/top_level.txt +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/requirements-dev.txt +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/setup.cfg +0 -0
- {python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/setup.py +0 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
v0.16.1 (2024-07-08)
|
|
2
|
+
--------------------
|
|
3
|
+
|
|
4
|
+
- Added official support for Python 3.12
|
|
5
|
+
- Proper error message when trying to use an unsupported combination of Pandas option
|
|
6
|
+
and archives with default values (issue #106).
|
|
7
|
+
|
|
1
8
|
v0.16.0 (2023-11-13)
|
|
2
9
|
--------------------
|
|
3
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-dwca-reader
|
|
3
|
-
Version: 0.16.
|
|
3
|
+
Version: 0.16.1
|
|
4
4
|
Summary: A simple Python package to read Darwin Core Archive (DwC-A) files.
|
|
5
5
|
Home-page: https://github.com/BelgianBiodiversityPlatform/python-dwca-reader
|
|
6
6
|
Author: Nicolas Noé - Belgian Biodiversity Platform
|
|
@@ -10,6 +10,8 @@ from tempfile import mkdtemp
|
|
|
10
10
|
from typing import List, Optional, Dict, Any, IO, Tuple
|
|
11
11
|
from xml.etree.ElementTree import Element
|
|
12
12
|
|
|
13
|
+
from pandas.io.parsers import TextFileReader
|
|
14
|
+
|
|
13
15
|
import dwca.vendor
|
|
14
16
|
from dwca.descriptors import ArchiveDescriptor, DataFileDescriptor, shorten_term
|
|
15
17
|
from dwca.exceptions import RowNotFound, InvalidArchive, InvalidSimpleArchive, NotADataFile
|
|
@@ -186,7 +188,9 @@ class DwCAReader(object):
|
|
|
186
188
|
.. note::
|
|
187
189
|
|
|
188
190
|
Default values of Darwin Core Archive are supported: A column will be added to the DataFrame if a term has
|
|
189
|
-
a default value in the Metafile (but no corresponding column in the CSV Data File).
|
|
191
|
+
a default value in the Metafile (but no corresponding column in the CSV Data File). This is unfortunately
|
|
192
|
+
not supported in case the value returned by `pandas.read_csv()` is a `TextFileReader` (e.g. when using
|
|
193
|
+
`chunksize` or `iterator=True`).
|
|
190
194
|
"""
|
|
191
195
|
datafile_descriptor = self.get_descriptor_for(relative_path) # type: DataFileDescriptor
|
|
192
196
|
|
|
@@ -200,15 +204,25 @@ class DwCAReader(object):
|
|
|
200
204
|
kwargs['header'] = None
|
|
201
205
|
kwargs['names'] = datafile_descriptor.short_headers
|
|
202
206
|
|
|
203
|
-
|
|
207
|
+
df_or_textreader = read_csv(self.absolute_temporary_path(relative_path), **kwargs)
|
|
204
208
|
|
|
205
209
|
# Add a column for default values, if present in the file descriptor
|
|
206
210
|
for field in datafile_descriptor.fields:
|
|
207
211
|
field_default_value = field['default']
|
|
208
212
|
if field_default_value is not None:
|
|
209
|
-
|
|
213
|
+
if isinstance(df_or_textreader, TextFileReader):
|
|
214
|
+
# I don't see how to assign default values to a TextFileReader, so
|
|
215
|
+
# this is currently unsupported
|
|
216
|
+
raise ValueError(
|
|
217
|
+
"Pandas read_csv() was called with a chunksize or iterator=True, "
|
|
218
|
+
"and therefore returns a TextFileReader instead of a DataFrame "
|
|
219
|
+
"which is not supported in combination with default values of "
|
|
220
|
+
"the archive."
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
df_or_textreader[shorten_term(field['term'])] = field_default_value
|
|
210
224
|
|
|
211
|
-
return
|
|
225
|
+
return df_or_textreader
|
|
212
226
|
|
|
213
227
|
def orphaned_extension_rows(self) -> Dict[str, Dict[str, List[int]]]:
|
|
214
228
|
"""Return a dict of the orphaned extension rows.
|
|
@@ -434,6 +448,7 @@ class DwCAReader(object):
|
|
|
434
448
|
except zipfile.BadZipfile:
|
|
435
449
|
# Doesn't look like a valid zip, let's see if it's a tar archive (possibly compressed)
|
|
436
450
|
try:
|
|
451
|
+
# TODO: Once we only support Python 3.12+, we should pass the filter="data" argument to extractall()
|
|
437
452
|
tarfile.open(self.archive_path, 'r:*').extractall(tmp_dir)
|
|
438
453
|
except tarfile.ReadError:
|
|
439
454
|
raise InvalidArchive("The archive cannot be read. Is it a .zip or .tgz file?")
|
|
@@ -48,6 +48,26 @@ class TestPandasIntegration(unittest.TestCase):
|
|
|
48
48
|
assert df["scientificName"].values.tolist() == \
|
|
49
49
|
["tetraodon fluviatilis", "betta splendens"]
|
|
50
50
|
|
|
51
|
+
def test_pd_read_chunked_default_value(self):
|
|
52
|
+
"""Pandas chuncksize should not be used with default values.
|
|
53
|
+
|
|
54
|
+
See: https://github.com/BelgianBiodiversityPlatform/python-dwca-reader/issues/106
|
|
55
|
+
"""
|
|
56
|
+
with DwCAReader(sample_data_path("dwca-test-default.zip")) as dwca:
|
|
57
|
+
with pytest.raises(ValueError):
|
|
58
|
+
for chunk in dwca.pd_read("occurrence.txt", chunksize=1):
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
def test_pd_read_chunked(self):
|
|
62
|
+
"""If no default values are available in the archive, chunksize should work.
|
|
63
|
+
|
|
64
|
+
See: https://github.com/BelgianBiodiversityPlatform/python-dwca-reader/issues/106
|
|
65
|
+
"""
|
|
66
|
+
with DwCAReader(sample_data_path("dwca-simple-test-archive.zip")) as dwca:
|
|
67
|
+
for chunk in dwca.pd_read("occurrence.txt", chunksize=2):
|
|
68
|
+
assert isinstance(chunk, pd.DataFrame)
|
|
69
|
+
|
|
70
|
+
|
|
51
71
|
def test_pd_read_no_data_files(self):
|
|
52
72
|
with DwCAReader(sample_data_path("dwca-simple-test-archive.zip")) as dwca:
|
|
53
73
|
with pytest.raises(NotADataFile):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.16.1'
|
{python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-dwca-reader
|
|
3
|
-
Version: 0.16.
|
|
3
|
+
Version: 0.16.1
|
|
4
4
|
Summary: A simple Python package to read Darwin Core Archive (DwC-A) files.
|
|
5
5
|
Home-page: https://github.com/BelgianBiodiversityPlatform/python-dwca-reader
|
|
6
6
|
Author: Nicolas Noé - Belgian Biodiversity Platform
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.16.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/dwca/darwincore/build_dc_terms_list.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python-dwca-reader-0.16.0 → python-dwca-reader-0.16.1}/python_dwca_reader.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|