Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymarc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander DelPriore
pymarc
Commits
c12467f0
Commit
c12467f0
authored
10 years ago
by
Ed Summers
Browse files
Options
Downloads
Plain Diff
Merge branch 'python3' again (with an up to date python3 branch)
parents
d15ead11
bcc6c27d
No related branches found
Branches containing commit
Tags
v3.1.4
v3.1.5
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+14
-11
14 additions, 11 deletions
README.md
pymarc/marcxml.py
+1
-1
1 addition, 1 deletion
pymarc/marcxml.py
pymarc/reader.py
+1
-1
1 addition, 1 deletion
pymarc/reader.py
with
16 additions
and
13 deletions
README.md
+
14
−
11
View file @
c12467f0
...
...
@@ -31,9 +31,10 @@ available here in pymarc repository:
```
python
from
pymarc
import
MARCReader
reader
=
MARCReader
(
open
(
'
test/marc.dat
'
))
for
record
in
reader
:
print
record
.
title
()
with
open
(
'
test/marc.dat
'
,
'
rb
'
)
as
fh
:
reader
=
MARCReader
(
fh
)
for
record
in
reader
:
print
(
record
.
title
())
```
```
The pragmatic programmer :from journeyman to master /
...
...
@@ -70,7 +71,7 @@ For example the `title` method extracts the information from the `245` field,
subfields
`a`
and
`b`
. You can access
`245a`
like so:
```
python
print
record
[
'
245
'
][
'
a
'
]
print
(
record
[
'
245
'
][
'
a
'
]
)
```
Some fields like subjects can repeat. In cases like that you will want to use
...
...
@@ -79,7 +80,7 @@ interact with further:
```
python
for
f
in
record
.
get_fields
(
'
650
'
):
print
f
print
(
f
)
```
If you are new to MARC fields
[
Understanding
...
...
@@ -102,7 +103,7 @@ record.add_field(
'
b
'
,
'
from journeyman to master /
'
,
'
c
'
,
'
Andrew Hunt, David Thomas.
'
]))
out
=
open
(
'
file.dat
'
,
'
w
'
)
out
=
open
(
'
file.dat
'
,
'
w
b
'
)
out
.
write
(
record
.
as_marc
())
out
.
close
()
```
...
...
@@ -114,10 +115,12 @@ again:
```
python
from
pymarc
import
MARCReader
reader
=
MARCReader
(
open
(
'
test/marc.dat
'
))
record
=
reader
.
next
()
record
[
'
245
'
][
'
a
'
]
=
'
The Zombie Programmer
'
out
=
open
(
'
file.dat
'
,
'
w
'
)
with
open
(
'
test/marc.dat
'
,
'
rb
'
)
as
fh
:
reader
=
MARCReader
(
fh
)
record
=
next
(
reader
)
record
[
'
245
'
][
'
a
'
]
=
'
The Zombie Programmer
'
out
=
open
(
'
file.dat
'
,
'
wb
'
)
out
.
write
(
record
.
as_marc
())
out
.
close
()
```
...
...
@@ -164,7 +167,7 @@ channel on [Freenode](http://freenode.net) is a good place for both.
Copyright
---------
Copyright (c) 2005-2014 Gabriel Farrell, Mark Matienzo, Ed Summers
Copyright (c) 2005-2014 Gabriel Farrell, Mark Matienzo,
Geoffrey Spear,
Ed Summers
License
-------
...
...
This diff is collapsed.
Click to expand it.
pymarc/marcxml.py
+
1
−
1
View file @
c12467f0
...
...
@@ -106,7 +106,7 @@ def map_xml(function, *files):
parsed the function will get called with the extracted record
def do_it(r):
print
r
print
(r)
map_xml(do_it,
'
marc.xml
'
)
"""
...
...
This diff is collapsed.
Click to expand it.
pymarc/reader.py
+
1
−
1
View file @
c12467f0
...
...
@@ -103,7 +103,7 @@ def map_records(f, *files):
pass in multiple batches.
>>>
def
print_title
(
r
):
>>>
print
r
[
'
245
'
]
>>>
print
(
r
[
'
245
'
]
)
>>>
>>>
map_records
(
print_title
,
file
(
'
marc.dat
'
))
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment