https://github.com/slub/replacemarcchars
a commandline command (Python3 program) that takes binary MARC records (e.g. originally stored in a JSON value) as input and replace some characters in it to be really binary MARC compatible
https://github.com/slub/replacemarcchars
command-line-tool encoding marc python
Last synced: 2 months ago
JSON representation
a commandline command (Python3 program) that takes binary MARC records (e.g. originally stored in a JSON value) as input and replace some characters in it to be really binary MARC compatible
- Host: GitHub
- URL: https://github.com/slub/replacemarcchars
- Owner: slub
- License: apache-2.0
- Created: 2019-05-10T13:22:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-21T10:38:33.000Z (about 7 years ago)
- Last Synced: 2025-01-25T07:08:53.004Z (over 1 year ago)
- Topics: command-line-tool, encoding, marc, python
- Language: Python
- Size: 8.79 KB
- Stars: 2
- Watchers: 8
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# replacemarcchars - replace binary MARC characters
replacemarcchars is a commandline command (Python3 program) that takes binary MARC records/lines (e.g. originally stored in a JSON value) as input and replace some characters in it to be really binary MARC compatible.
Following replace methods are available:
* **decimal**: replaces '#29;', '#30;', '#31;' with "\x1D", "\x1E", "\x1F"
* **unicode**: replaces '\u001d', '\u001e', '\u001f' with "\x1D", "\x1E", "\x1F"
* **hex**: replaces '\x1D', '\x1E', '\x1F' with "\x1D", "\x1E", "\x1F"
## Usage
```
replacemarcchars
optional arguments:
-h, --help show this help message and exit
-replace-method {decimal,unicode,hex} method for character replacement (default: decimal)
```
* example:
```
replacemarcchars < [BINARY MARC RECORDS/LINES FROM E.G. JSON VALUE] > [TRUE BINARY MARC]
```
## Run
* clone this git repo or just download the [replacemarcchars.py](replacemarcchars/replacemarccchars.py) file
* run ./replacemarcchars.py
* for a hackish way to use replacemarcchars system-wide, copy to /usr/local/bin
### Install system-wide via pip
* via pip:
```
sudo -H pip3 install --upgrade [ABSOLUTE PATH TO YOUR LOCAL GIT REPOSITORY OF REPLACEMARCCHARS]
```
(which provides you ```replacemarcchars``` as a system-wide commandline command)