@@ -43,26 +43,33 @@ poetry build
43
43
  ;
44
44
### Installation
45
45
46
- To use locally built package in a virtual environment for eg in preingestion or galaxias:
46
+ Install published package
47
+ ``` bash
48
+ pip install dwcahandler
49
+ ```
50
+
51
+ To use locally built package in a virtual environment:
47
52
``` bash
48
53
pip install < folder> /dwcahandler/dist/dwcahandler-< version> .tar.gz
49
54
```
50
55
51
- However, to install published package from testpypi
56
+ To install published package from testpypi
52
57
``` bash
53
58
pip install -i https://test.pypi.org/simple/ dwcahandler
54
59
```
55
60
  ;
56
61
### Examples of dwcahandler usages:
57
62
58
63
* Create Darwin Core Archive from csv file
64
+ * In creating a dwca with multimedia extension, provide format and type values in the Simple Multimedia extension, otherwise, dwcahandler will attempt to fill these info by guessing the mimetype from url.
65
+
59
66
``` python
60
67
from dwcahandler import CsvFileType
61
68
from dwcahandler import DwcaHandler
62
69
from dwcahandler import Eml
63
70
64
- core_csv = CsvFileType(files = [' /tmp/occurrence.csv' ], type = ' occurrence' , keys = ' occurrenceID' )
65
- ext_csvs = [CsvFileType(files = [' /tmp/multimedia.csv' ], type = ' multimedia' )]
71
+ core_csv = CsvFileType(files = [' /tmp/occurrence.csv' ], type = ' occurrence' , keys = [ ' occurrenceID' ] )
72
+ ext_csvs = [CsvFileType(files = [' /tmp/multimedia.csv' ], type = ' multimedia' , keys = [ ' occurrenceID ' ] )]
66
73
67
74
eml = Eml(dataset_name = ' Test Dataset' ,
68
75
description = ' Dataset description' ,
@@ -74,6 +81,8 @@ DwcaHandler.create_dwca(core_csv=core_csv, ext_csv_list=ext_csvs, eml_content=em
74
81
```
75
82
  ;
76
83
* Create Darwin Core Archive from pandas dataframe
84
+ * In creating a dwca with multimedia extension, provide format and type values in the Simple Multimedia extension, otherwise, dwcahandler will attempt to fill these info by guessing the mimetype from url.
85
+
77
86
``` python
78
87
from dwcahandler import DwcaHandler
79
88
from dwcahandler.dwca import DataFrameType
@@ -84,7 +93,7 @@ core_df = pd.read_csv("/tmp/occurrence.csv")
84
93
core_frame = DataFrameType(df = core_df, type = ' occurrence' , keys = [' occurrenceID' ])
85
94
86
95
ext_df = pd.read_csv(" /tmp/multimedia.csv" )
87
- ext_frame = [DataFrameType(df = ext_df, type = ' multimedia' )]
96
+ ext_frame = [DataFrameType(df = ext_df, type = ' multimedia' , keys = [ ' occurrenceID ' ] )]
88
97
89
98
eml = Eml(dataset_name = ' Test Dataset' ,
90
99
description = ' Dataset description' ,
@@ -93,6 +102,7 @@ eml = Eml(dataset_name='Test Dataset',
93
102
rights = " test rights" )
94
103
95
104
DwcaHandler.create_dwca(core_csv = core_frame, ext_csv_list = ext_frame, eml_content = eml, output_dwca_path = ' /tmp/dwca.zip' )
105
+
96
106
```
97
107
  ;
98
108
* Merge Darwin Core Archive
@@ -109,7 +119,7 @@ DwcaHandler.merge_dwca(dwca_file='/tmp/dwca.zip', delta_dwca_file='/tmp/delta-dw
109
119
from dwcahandler import CsvFileType
110
120
from dwcahandler import DwcaHandler
111
121
112
- delete_csv = CsvFileType(files = [' /tmp/old-records.csv' ], type = ' occurrence' , keys = ' occurrenceID' )
122
+ delete_csv = CsvFileType(files = [' /tmp/old-records.csv' ], type = ' occurrence' , keys = [ ' occurrenceID' ] )
113
123
114
124
DwcaHandler.delete_records(dwca_file = ' /tmp/dwca.zip' ,
115
125
records_to_delete = delete_csv,
@@ -118,7 +128,7 @@ DwcaHandler.delete_records(dwca_file='/tmp/dwca.zip',
118
128
  ;
119
129
* List darwin core terms that is supported in dwcahandler package
120
130
``` python
121
- from dwca import DwcaHandler
131
+ from dwcahandler import DwcaHandler
122
132
123
133
df = DwcaHandler.list_dwc_terms()
124
134
print (df)
@@ -132,7 +142,7 @@ class DerivedDwca(Dwca):
132
142
"""
133
143
Derived class to perform other custom operations that is not included as part of the core operations
134
144
"""
135
- def _drop_columns (self ):
145
+ def drop_columns (self ):
136
146
"""
137
147
Drop existing column in the core content
138
148
"""
@@ -141,10 +151,10 @@ class DerivedDwca(Dwca):
141
151
142
152
143
153
dwca = DerivedDwca(dwca_file_loc = ' /tmp/dwca.zip' )
144
- dwca._extract_dwca ()
145
- dwca._drop_columns ()
146
- dwca._generate_eml ()
147
- dwca._generate_meta ()
148
- dwca._write_dwca (' /tmp/newdwca.zip' )
154
+ dwca.extract_dwca ()
155
+ dwca.drop_columns ()
156
+ dwca.generate_eml ()
157
+ dwca.generate_meta ()
158
+ dwca.write_dwca (' /tmp/newdwca.zip' )
149
159
150
160
```
0 commit comments