Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCLC Processing of MARC Records #893

Merged
merged 4 commits into from
Mar 15, 2024
Merged

OCLC Processing of MARC Records #893

merged 4 commits into from
Mar 15, 2024

Conversation

jermnelson
Copy link
Collaborator

@jermnelson jermnelson commented Mar 12, 2024

Fixes #871

TODO:

  • Test on development

@jermnelson jermnelson force-pushed the t871-oclc-marc branch 4 times, most recently from 59d4bc7 to da47c85 Compare March 15, 2024 00:26
transformer = Transformer()
for marc_file in marc_file_list:
for marc_file in ast.literal_eval(marc_file_list):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running the DAG on development, the marc_file_list was coming in as string instead of as a list, this method call converts the string into a list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to see what this looked like and what it did...I assume something like this?

>>> file_list = "['path/to/file/1.txt', 'path/to/file/two.csv', 'path/to/file/3.txt']"
>>> type(file_list)
<class 'str'>
>>> type(ast.literal_eval(file_list))
<class 'list'>
>>> ast.dump(ast.parse(file_list))
"Module(body=[Expr(value=List(elts=[Constant(value='path/to/file/1.txt'), Constant(value='path/to/file/two.csv'), Constant(value='path/to/fil3/3.txt')], ctx=Load()))], type_ignores=[])"

pretty cool!
https://docs.python.org/3/library/ast.html#ast.List

@shelleydoljack ☝️

@jermnelson jermnelson marked this pull request as ready for review March 15, 2024 00:36
Copy link
Contributor

@jgreben jgreben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking changes, just a suggestion for the changing a variable name which wan't obvious to me at first pass.

codes.append(oclc_code)
return codes

def divide(self, marc_file):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a None return type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Updating.

transformer = Transformer()
for marc_file in marc_file_list:
for marc_file in ast.literal_eval(marc_file_list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to see what this looked like and what it did...I assume something like this?

>>> file_list = "['path/to/file/1.txt', 'path/to/file/two.csv', 'path/to/file/3.txt']"
>>> type(file_list)
<class 'str'>
>>> type(ast.literal_eval(file_list))
<class 'list'>
>>> ast.dump(ast.parse(file_list))
"Module(body=[Expr(value=List(elts=[Constant(value='path/to/file/1.txt'), Constant(value='path/to/file/two.csv'), Constant(value='path/to/fil3/3.txt')], ctx=Load()))], type_ignores=[])"

pretty cool!
https://docs.python.org/3/library/ast.html#ast.List

@shelleydoljack ☝️

transformer = OCLCTransformer()
for marc_file in ast.literal_eval(marc_file_list):
transformer.divide(marc_file)
transformer.save()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we name this variable oclc_transformer instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jermnelson jermnelson mentioned this pull request Mar 15, 2024
@jermnelson jermnelson merged commit 56a7e4e into main Mar 15, 2024
4 checks passed
@jermnelson jermnelson deleted the t871-oclc-marc branch March 15, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functions (and class methods) for applying OCLC rules to MARC for data export
2 participants