sas7bdat_converter 2.0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2021 Paul Sanders
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,405 @@
1
+ Metadata-Version: 2.1
2
+ Name: sas7bdat_converter
3
+ Version: 2.0.1
4
+ Summary: Convert sas7bdat and xport files into other formats
5
+ Home-page: https://github.com/sanders41/sas7bdat-converter
6
+ License: MIT
7
+ Keywords: sas,sas7bdat,converter,xpt,XPort
8
+ Author: Paul Sanders
9
+ Author-email: psanders1@gmail.com
10
+ Requires-Python: >=3.8.0,<4.0.0
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Typing :: Typed
20
+ Provides-Extra: all
21
+ Provides-Extra: excel
22
+ Provides-Extra: parquet
23
+ Requires-Dist: openpyxl (>=3.0.5) ; extra == "excel" or extra == "all"
24
+ Requires-Dist: pandas (>=1.2.0)
25
+ Requires-Dist: pyarrow (>=9.0.0,<13.0.0) ; extra == "parquet" or extra == "all"
26
+ Project-URL: Documentation, https://github.com/sanders41/sas7bdat-converter
27
+ Project-URL: Repository, https://github.com/sanders41/sas7bdat-converter
28
+ Description-Content-Type: text/markdown
29
+
30
+ # sas7bdat-converter: Convert sas7bdat files into other formats
31
+
32
+ [![Tests Status](https://github.com/sanders41/sas7bdat-converter/workflows/Tests/badge.svg?branch=main&event=push)](https://github.com/sanders41/sas7bdat-converter/actions?query=workflow%3ATests+branch%3Amain+event%3Apush)
33
+ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/sas7bdat-converter/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/sas7bdat-converter/main)
34
+ [![Coverage](https://codecov.io/github/sanders41/sas7bdat-converter/coverage.svg?branch=main)](https://codecov.io/gh/sanders41/sas7bdat-converter)
35
+ [![PyPI version](https://badge.fury.io/py/sas7bdat-converter.svg)](https://badge.fury.io/py/sas7bdat-converter)
36
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sas7bdat-converter?color=5cc141)](https://github.com/sanders41/sas7bdat-converter)
37
+
38
+ Converts proprietary sas7bdat and/or xport files from SAS into formats such as csv, json, and Excel useable
39
+ by other programs. Currently supported conversiaions are csv, Excel (xlsx format), json, Pandas
40
+ DataFrame, Parquet and XML.
41
+
42
+ Conversions can be done on either a single file, an entire directory, or a batch of specified files.
43
+
44
+ ## Install
45
+
46
+ `pip install sas7bdat-converter`
47
+
48
+ If you would like to be able to convert to Excel files you will need to install with the extra Excel dependency.
49
+
50
+ `pip install sas7bdat-converter[excel]`
51
+
52
+ If you would like to be able to convert to Parquet files you will need to install with the extra parquet dependency.
53
+
54
+ `pip install sas7bdat-converter[parquet]`
55
+
56
+ If you would like to use Conda, it includes both the extras required to convert to Excel & Parquet files.
57
+
58
+ `conda install -c conda-forge sas7bdat-converter`
59
+
60
+ ## Usage
61
+
62
+ In all cases either sas7bdat or xport files can be converted. Examples below all use the .sas7bdat
63
+ extension, xport files with a .xpt extension will also work.
64
+
65
+ * **batch_to_csv(file_dicts)** - Convert multiple sas7bdat files into csv files at once.
66
+ * file_dicts = A list containing a dictionary for each file to convert. The dictionary is required
67
+ to contain 'sas7bdat_file' containing the path and name for the sas7bdat file, and 'export_file'
68
+ containing the path and name for the csv files. The csv file extension should be .csv. File paths
69
+ can be sent as either strings or Path objects.
70
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
71
+ file conversion error instead of raising an exception. Default = False
72
+
73
+ **Example**
74
+
75
+ ```py
76
+ import sas7bdat_converter
77
+
78
+ file_dicts = [
79
+ {
80
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_1.sas7bdat',
81
+ 'export_file': '/path/to/new/files/example_1.csv',
82
+ },
83
+ {
84
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_2.sas7bdat',
85
+ 'export_file': '/path/to/new/files/example_2.csv',
86
+ },
87
+ ]
88
+ sas7bdat_converter.batch_to_csv(file_dicts)
89
+ ```
90
+
91
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
92
+ `c:\path\to\sas7bdat\files\example_1.sas7bdat`.
93
+
94
+ * **batch_to_excel(file_dicts)** - Convert multiple sas7bdat files into Excel files at once.
95
+ * file_dicts = A list containing a dictionary for each file to convert. The dictionary is required
96
+ to contain 'sas7bdat_file' containing the path and name for the sas7bdat file, and 'export_file'
97
+ containing the path and name for the excel files. The Excel file extension should be .xlsx. File
98
+ paths can be sent as either strings or Path objects.
99
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
100
+ file conversion error instead of raising an exception. Default = False
101
+
102
+ **Example**
103
+
104
+ ```py
105
+ import sas7bdat_converter
106
+
107
+ file_dicts = [
108
+ {
109
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_1.sas7bdat',
110
+ 'export_file': '/path/to/new/files/example_1.xlsx',
111
+ },
112
+ {
113
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_2.sas7bdat',
114
+ 'export_file': '/path/to/new/files/example_2.xlsx',
115
+ },
116
+ ]
117
+ sas7bdat_converter.batch_to_excel(file_dicts)
118
+ ```
119
+
120
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
121
+ `c:\path\to\sas7bdat\files\example_1.sas7bdat`.
122
+
123
+ * **batch_to_parquet(file_dicts)** - Convert multiple sas7bdat files into Parquet files at once.
124
+ * file_dicts = A list containing a dictionary for each file to convert. The dictionary is required
125
+ to contain 'sas7bdat_file' containing the path and name for the sas7bdat file, and 'export_file'
126
+ containing the path and name for the perquet files. The Perquet file extension should be .perquet. File
127
+ paths can be sent as either strings or Path objects.
128
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
129
+ file conversion error instead of raising an exception. Default = False
130
+
131
+ **Example**
132
+
133
+ ```py
134
+ import sas7bdat_converter
135
+
136
+ file_dicts = [
137
+ {
138
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_1.sas7bdat',
139
+ 'export_file': '/path/to/new/files/example_1.parquet',
140
+ },
141
+ {
142
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_2.sas7bdat',
143
+ 'export_file': '/path/to/new/files/example_2.parquet',
144
+ },
145
+ ]
146
+ sas7bdat_converter.batch_to_parquet(file_dicts)
147
+ ```
148
+
149
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
150
+ `c:\path\to\sas7bdat\files\example_1.sas7bdat`.
151
+
152
+ * **batch_to_json(file_dicts)** - Convert multiple sas7bdat files into json files at once.
153
+ * file_dicts = A list containing a dictionary for each file to convert. The dictionary is required
154
+ to contain 'sas7bdat_file' containing the path and name for the sas7bdat file, and 'export_file'
155
+ containing the path and name for the json files. The json file extension should be .json. File
156
+ paths can be sent as either strings or Path objects.
157
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
158
+ file conversion error instead of raising an exception. Default = False
159
+
160
+ **Example**
161
+
162
+ ```py
163
+ import sas7bdat_converter
164
+
165
+ file_dicts = [
166
+ {
167
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_1.sas7bdat',
168
+ 'export_file': '/path/to/new/files/example_1.json',
169
+ },
170
+ {
171
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_2.sas7bdat',
172
+ 'export_file': '/path/to/new/files/example_2.json',
173
+ },
174
+ ]
175
+ sas7bdat_converter.batch_to_json(file_dicts)
176
+ ```
177
+
178
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
179
+ `c:\path\to\sas7bdat\files\example_1.sas7bdat`.
180
+
181
+ * **batch_to_xml(file_dicts)** - Convert multiple sas7bdat files into XML files at once.
182
+ * file_dicts = A list containing a dictionary for each file to convert. The dictionary is required
183
+ to contain 'sas7bdat_file' containing the path and name for the sas7bdat file, and 'export_file'
184
+ containing the path and name for the xml files. The XML file extension should be .xml. File paths
185
+ can be sent as either strings or Path objects.
186
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
187
+ file conversion error instead of raising an exception. Default = False
188
+
189
+ **Example**
190
+
191
+ ```py
192
+ import sas7bdat_converter
193
+
194
+ file_dicts = [
195
+ {
196
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_1.sas7bdat',
197
+ 'export_file': '/path/to/new/files/example_1.xml',
198
+ },
199
+ {
200
+ 'sas7bdat_file': '/path/to/sas7bdat/files/example_2.sas7bdat',
201
+ 'export_file': '/path/to/new/files/example_2.xml',
202
+ },
203
+ ]
204
+ sas7bdat_converter.batch_to_xml(file_dicts)
205
+ ```
206
+
207
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
208
+ `c:\path\to\sas7bdat\files\example_1.sas7bdat`.
209
+
210
+ * **dir_to_csv(dir_path, export_path=None)** - Convert all sas7bdat files in a directory into csv
211
+ files at once. File paths can be sent as either strings or Path objects.
212
+ * dir_path = The dictionary that contains the sas7bdat file to convert.
213
+ * export_path = Optional path for the converted files. If no path is supplied the new files will
214
+ be put into the dir_path directory with the sas7bdat files. File paths can be sent as either
215
+ strings or Path objects. Default = None
216
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
217
+ file conversion error instead of raising an exception. Default = False
218
+
219
+ **Example**
220
+
221
+ ```py
222
+ import sas7bdat_converter
223
+
224
+ # Option 1: put the converted files in the same directory as the sas7bdat files
225
+ sas7bdat_converter.dir_to_csv('/path/to/sas7bdat/files')
226
+
227
+ # Option 2: put the converted fiels in a diffferent directory
228
+ sas7bdat_converter.dir_to_csv('/path/to/sas7bdat/files', 'path/for/new/files')
229
+ ```
230
+
231
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
232
+ `c:\path\to\sas7bdat\files`.
233
+
234
+ * **dir_to_excel(dir_path, export_path=None)** - Convert all sas7bdat files in a directory into
235
+ Excel files at once. File paths can be sent as either strings or Path objects.
236
+ * dir_path = The dictionary that contains the sas7bdat file to convert.
237
+ * export_path = Optional path for the converted files. If no path is supplied the new files will
238
+ be put into the dir_path directory with the sas7bdat files Default = None
239
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
240
+ file conversion error instead of raising an exception. Default = False
241
+
242
+ **Example**
243
+
244
+ ```py
245
+ import sas7bdat_converter
246
+
247
+ # Option 1: put the converted files in the same directory as the sas7bdat files
248
+ sas7bdat_converter.dir_to_excel('/path/to/sas7bdat/files')
249
+
250
+ # Option 2: put the converted fiels in a diffferent directory
251
+ sas7bdat_converter.dir_to_excel('/path/to/sas7bdat/files', 'path/for/new/files')
252
+ ```
253
+
254
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
255
+ `c:\path\to\sas7bdat\files`.
256
+
257
+ * **dir_to_json(dir_path, export_path=None)** - Convert all sas7bdat files in a directory into json
258
+ files at once. File paths can be sent as either strings or Path objects.
259
+ * dir_path = The dictionary that contains the sas7bdat file to convert.
260
+ * export_path = Optional path for the converted files. If no path is supplied the new files will
261
+ be put into the dir_path directory with the sas7bdat files. Default = None
262
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
263
+ file conversion error instead of raising an exception. Default = False
264
+
265
+ **Example**
266
+
267
+ ```py
268
+ import sas7bdat_converter
269
+
270
+ # Option 1: put the converted files in the same directory as the sas7bdat files
271
+ sas7bdat_converter.dir_to_json('/path/to/sas7bdat/files')
272
+
273
+ # Option 2: put the converted fiels in a diffferent directory
274
+ sas7bdat_converter.dir_to_json('/path/to/sas7bdat/files', 'path/for/new/files')
275
+ ```
276
+
277
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
278
+ `c:\path\to\sas7bdat\files`.
279
+
280
+ * **dir_to_xml(dir_path, export_path=None)** - Convert all sas7bdat files in a directory into XML
281
+ files at once. File paths can be sent as either strings or Path objects.
282
+ * dir_path = The dictionary that contains the sas7bdat file to convert.
283
+ * export_path = Optional path for the converted files. If no path is supplied the new files will
284
+ be put into the dir_path directory with the sas7bdat files. Default = None
285
+ * continue_on_error = If set to true processing of files in a batch will continue if there is a
286
+ file conversion error instead of raising an exception. Default = False
287
+
288
+ **Example**
289
+
290
+ ```py
291
+ import sas7bdat_converter
292
+
293
+ # Option 1: put the converted files in the same directory as the sas7bdat files
294
+ sas7bdat_converter.dir_to_xml('/path/to/sas7bdat/files')
295
+
296
+ # Option 2: put the converted fiels in a diffferent directory
297
+ sas7bdat_converter.dir_to_xml('/path/to/sas7bdat/files', 'path/for/new/files')
298
+ ```
299
+
300
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
301
+ `c:\path\to\sas7bdat\files`.
302
+
303
+ * **to_csv(sas7bdat_file, export_file)** - convert a sas7bdat file into a csv file. File path can be
304
+ sent as either a string or Path objects.
305
+ * sas7bdat_file = the path and name for sas7bdat file to convert.
306
+ * export_file = the path and name for the csv file. The csv file extension should be .csv.
307
+
308
+ **Example**
309
+
310
+ ```py
311
+ import sas7bdat_converter
312
+
313
+ sas7bdat_converter.to_csv('/path/to/sas7bdat/file/example.sas7bdat', 'path/to/new/file/example.csv')
314
+ ```
315
+
316
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
317
+ `c:\path\to\sas7bdat\files\example.sas7bdat`.
318
+
319
+ * **to_dataframe(sas7bdat_file)** - Convert a sas7bdat file into a Pandas DataFrame. File path can
320
+ be sent as either a string or Path objects.
321
+ * sas7bdat_file = The path and name for sas7bdat file to convert.
322
+
323
+ **Example**
324
+
325
+ ```py
326
+ import sas7bdat_converter
327
+
328
+ sas7bdat_converter.to_dataframe('/path/to/sas7bdat/file/example.sas7bdat')
329
+ ```
330
+
331
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
332
+ `c:\path\to\sas7bdat\files\example_1.sas7bdat`.
333
+
334
+ * **to_excel(sas7bdat_file, export_file)** - convert a sas7bdat file into a Excel file. File path
335
+ can be sent as either a string or Path objects.
336
+ * sas7bdat_file = the path and name for sas7bdat file to convert.
337
+ * export_file = the path and name for the Excel file. The Excel file extension should be .xlsx.
338
+
339
+ **Example**
340
+
341
+ ```py
342
+ import sas7bdat_converter
343
+
344
+ sas7bdat_converter.to_excel('/path/to/sas7bdat/file/example.sas7bdat',
345
+ 'path/to/new/file/example.xlsx')
346
+ ```
347
+
348
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
349
+ `c:\path\to\sas7bdat\files\example.sas7bdat`.
350
+
351
+ * **to_parquet(sas7bdat_file, export_file)** - convert a sas7bdat file into a Parquet file. File path
352
+ can be sent as either a string or Path objects.
353
+ * sas7bdat_file = the path and name for sas7bdat file to convert.
354
+ * export_file = the path and name for the Parquet file. The Parquet file extension should be .parquet.
355
+
356
+ **Example**
357
+
358
+ ```py
359
+ import sas7bdat_converter
360
+
361
+ sas7bdat_converter.to_parquet('/path/to/sas7bdat/file/example.sas7bdat',
362
+ 'path/to/new/file/example.parquet')
363
+ ```
364
+
365
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
366
+ `c:\path\to\sas7bdat\files\example.sas7bdat`.
367
+
368
+ * **to_json(sas7bdat_file, export_file)** - convert a sas7bdat file into a json file. File path can
369
+ be sent as either a string or Path objects.
370
+ * sas7bdat_file = the path and name for sas7bdat file to convert.
371
+ * export_file = the path and name for the json file. the json file extension should be .json.
372
+
373
+ **Example**
374
+
375
+ ```py
376
+ import sas7bdat_converter
377
+
378
+ sas7bdat_converter.to_json('/path/to/sas7bdat/file/example.sas7bdat', 'path/to/new/file/example.json')
379
+ ```
380
+
381
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
382
+ `c:\path\to\sas7bdat\files\example.sas7bdat`.
383
+
384
+ * **to_xml(sas7bdat_file, export_file, root_node='root', first_node='item')** - convert a sas7bdat
385
+ file into a XML file. File path can be sent as either a string or Path objects.
386
+ * sas7bdat_file = the path and name for sas7bdat file to convert.
387
+ * export_file = the path and name for the XML file. The XML file extension should be .xlm.
388
+ * root_node = The name to uses for the top level node. If no name is supplied "root" will be used.
389
+ * first_node = The name to use for the first node under root. If no name is supplied "item" will be used.
390
+
391
+ **Example**
392
+
393
+ ```py
394
+ import sas7bdat_converter
395
+
396
+ sas7bdat_converter.to_xml('/path/to/sas7bdat/file/example.sas7bdat', 'path/to/new/file/example.xml')
397
+ ```
398
+
399
+ **Note:** Example uses Mac/Linux type file paths. For Windows use paths like
400
+ `c:\path\to\sas7bdat\files\example.sas7bdat`.
401
+
402
+ ## Contributing
403
+
404
+ If you are interested in contributing to this project please see our [contributing guide](CONTRIBUTING.md)
405
+