You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 05-More-Fix-Concepts.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,7 +204,7 @@ colours:
204
204
and you use the fix
205
205
206
206
```PERL
207
-
add_arrayy("result") # To create a new array named result
207
+
add_array("result") # To create a new array named result
208
208
209
209
upcase("colours[].*")
210
210
append("colours[].*"," is a nice color")
@@ -228,31 +228,31 @@ If you want to only change it, under a certain condition:
228
228
229
229
```PERL
230
230
if any_equal("colours[]","green")
231
-
add_arrayy("result[]") # To create a new array named result
231
+
add_array("result[]") # To create a new array named result
232
232
upcase("colours[].*")
233
233
append("colours[].*"," is a nice color")
234
234
copy_field("colours[].*","result[].$append")
235
235
end
236
236
```
237
237
238
-
[This still transforms the all elements of an array because the conditional tests all elements not each individually.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=if+any_equal%28%22colours%5B%5D%22%2C%22green%22%29%0A++add_arrayy%28%22result%22%29+%23+To+create+a+new+array+named+result%0A%0A++upcase%28%22colours%5B%5D.%2A%22%29%0A++append%28%22colours%5B%5D.%2A%22%2C%22+is+a+nice+color%22%29%0A++copy_field%28%22colours%5B%5D.%2A%22%2C%22result.%24append%22%29%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
238
+
[This still transforms the all elements of an array because the conditional tests all elements not each individually.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=if+any_equal%28%22colours%5B%5D%22%2C%22green%22%29%0A++add_array%28%22result%22%29+%23+To+create+a+new+array+named+result%0A%0A++upcase%28%22colours%5B%5D.%2A%22%29%0A++append%28%22colours%5B%5D.%2A%22%2C%22+is+a+nice+color%22%29%0A++copy_field%28%22colours%5B%5D.%2A%22%2C%22result.%24append%22%29%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
239
239
To only tranform and copy the value `green` to an X you have to use the `do list`-Bind:
240
240
241
241
```PERL
242
242
do list(path:"colours[]","var":"$i")
243
243
if any_equal("$i","green")
244
-
add_arrayy("result[]") # To create a new array named result
244
+
add_array("result[]") # To create a new array named result
245
245
upcase("$i")
246
246
append("$i"," is a nice color")
247
247
copy_field("$i","result[].$append")
248
248
end
249
249
end
250
250
```
251
251
252
-
[See this example here in the playground.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=do+list%28path%3A%22colours%5B%5D%22%2C%22var%22%3A%22%24i%22%29%0A++++if+any_equal%28%22%24i%22%2C%22green%22%29%0A++++++++add_arrayy%28%22result%5B%5D%22%29+%23+To+create+a+new+array+named+result%0A++++++++upcase%28%22%24i%22%29%0A++++++++append%28%22%24i%22%2C%22+is+a+nice+color%22%29%0A++++++++copy_field%28%22%24i%22%2C%22result%5B%5D.%24append%22%29%0A++++end%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
252
+
[See this example here in the playground.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=do+list%28path%3A%22colours%5B%5D%22%2C%22var%22%3A%22%24i%22%29%0A++++if+any_equal%28%22%24i%22%2C%22green%22%29%0A++++++++add_array%28%22result%5B%5D%22%29+%23+To+create+a+new+array+named+result%0A++++++++upcase%28%22%24i%22%29%0A++++++++append%28%22%24i%22%2C%22+is+a+nice+color%22%29%0A++++++++copy_field%28%22%24i%22%2C%22result%5B%5D.%24append%22%29%0A++++end%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
253
253
254
254
TO BE CONTINUED ...
255
255
256
-
TODO: Add Excercises.
256
+
TODO: Add more Excercises.
257
257
258
258
Next lesson: [06 Metafacture CLI](./06_MetafactureCLI.md)
@@ -320,7 +320,7 @@ HINT: Sometimes it makes sense to create an empty array by `add_array` or an emp
320
320
321
321
```
322
322
323
-
[See it in the Playground here.](https://metafacture.org/playground/?flux=%22https%3A//raw.githubusercontent.com/metafacture/metafacture-tutorial/main/data/sample.mrc%22%0A%7C+open-http%0A%7C+as-lines%0A%7C+decode-marc21%0A%7C+fix%28transformationFile%29%0A%7C+encode-csv%28includeheader%3D%22true%22%29%0A%7C+print%0A%3B%0A%0A&transformation=copy_field%28%22001%22%2C%22id%22%29%0Aadd_arrayy%28%22title%22%29%0Ado+list%28path%3A+%22245%3F%3F.%3F%22%2C%22var%22%3A%22%24i%22%29%0A++copy_field%28%22%24i%22%2C%22title.%24append%22%29%0Aend%0Ajoin_field%28title%2C%22+%22%29%0Aadd_arrayy%28%22isbn%22%29%0Ado+list%28path%3A+%22020%3F%3F.a%22%2C%22var%22%3A%22%24i%22%29%0A++copy_field%28%22%24i%22%2Cisbn.%24append%29%0Aend%0Ajoin_field%28isbn%2C%22%2C%22%29%0Aretain%28%22id%22%2C%22title%22%2C%22isbn%22%29)
323
+
[See it in the Playground here.](https://metafacture.org/playground/?flux=%22https%3A//raw.githubusercontent.com/metafacture/metafacture-tutorial/main/data/sample.mrc%22%0A%7C+open-http%0A%7C+as-lines%0A%7C+decode-marc21%0A%7C+fix%28transformationFile%29%0A%7C+encode-csv%28includeheader%3D%22true%22%29%0A%7C+print%0A%3B%0A%0A&transformation=copy_field%28%22001%22%2C%22id%22%29%0Aadd_array%28%22title%22%29%0Ado+list%28path%3A+%22245%3F%3F.%3F%22%2C%22var%22%3A%22%24i%22%29%0A++copy_field%28%22%24i%22%2C%22title.%24append%22%29%0Aend%0Ajoin_field%28title%2C%22+%22%29%0Aadd_array%28%22isbn%22%29%0Ado+list%28path%3A+%22020%3F%3F.a%22%2C%22var%22%3A%22%24i%22%29%0A++copy_field%28%22%24i%22%2Cisbn.%24append%29%0Aend%0Ajoin_field%28isbn%2C%22%2C%22%29%0Aretain%28%22id%22%2C%22title%22%2C%22isbn%22%29)
324
324
325
325
326
326
You will see this as output:
@@ -339,7 +339,7 @@ You will see this as output:
339
339
"1080278184","Renfro Valley Kentucky Rainer H. Schmeissner",""
340
340
```
341
341
342
-
In the fix above we mapped the 245-field to the title, and iterated over every subfield with the help of the list-bind and the `?`- wildcard. The ISBN is in the 020-field. Because MARC records can contain one or more 020 fields we created an isbn array with add_arrayy and added the values using the isbn.$append syntax. Next we turned the isbn array back into a comma separated string using the join_field fix. As last step we deleted all the fields we didn’t need in the output with the `retain` syntax.
342
+
In the fix above we mapped the 245-field to the title, and iterated over every subfield with the help of the list-bind and the `?`- wildcard. The ISBN is in the 020-field. Because MARC records can contain one or more 020 fields we created an isbn array with add_array and added the values using the isbn.$append syntax. Next we turned the isbn array back into a comma separated string using the join_field fix. As last step we deleted all the fields we didn’t need in the output with the `retain` syntax.
343
343
344
344
Different versions of MARC-Serialization need different workflows: e.g. h[ere see an example of Aseq-Marc Files that are transformed to marcxml.](https://test.metafacture.org/playground/?flux=%22https%3A//raw.githubusercontent.com/LibreCat/Catmandu-MARC/dev/t/rug01.aleph%22%0A%7C+open-http%0A%7C+as-lines%0A%7C+decode-aseq%0A%7C+merge-same-ids%0A%7C+encode-marcxml%0A%7C+print%0A%3B)
Copy file name to clipboardExpand all lines: 11_MARC_to_Dublin_Core.md
+13-18Lines changed: 13 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
-
# TODO : Lesson 11 : From MARC to Dublin Core as loud JSON-LD
2
-
TODO: Use better example. https://github.com/metafacture/metafacture-examples/blob/master/Swissbib-Extensions/MARC-CSV/
1
+
# Lesson 11 : From MARC to Dublin Core as loud JSON-LD
2
+
TODO: Use better example. But the following is missing isbns: https://github.com/metafacture/metafacture-examples/blob/master/Swissbib-Extensions/MARC-CSV/
3
3
4
4
Today we will look a bit further into MARC processing with Metafacture. We already saw a bit of MARC processing in and today we will show you how to transform MARC records into Dublin Core and providing the data as linked open usable data.
5
5
@@ -9,22 +9,22 @@ And type into this textfile the following fixes:
9
9
10
10
```PERL
11
11
copy_field("245??.a","title")
12
-
add_arrayy("creator[]")
12
+
add_array("creator[]")
13
13
copy_field("100??.a","creator[].$append")
14
14
copy_field("700??.a","creator[].$append")
15
15
copy_field("260??.c","date")
16
16
copy_field("260??.b","publisher")
17
17
18
-
add_arrayy("isbn[]")
18
+
add_array("isbn[]")
19
19
do list(path:"020??","var":"$i")
20
20
copy_field("$i.a","isbn[].$append")
21
21
end
22
-
add_arrayy("issn[]")
22
+
add_array("issn[]")
23
23
do list(path:"022??","var":"$i")
24
24
copy_field("$i.a","issn[].$append")
25
25
end
26
26
27
-
add_arrayy("subject[]")
27
+
add_array("subject[]")
28
28
do list(path:"650??","var":"$i")
29
29
copy_field("$i.a","subject[].$append")
30
30
end
@@ -87,10 +87,10 @@ Congratulations, you’ve created your first mapping file to transform library d
87
87
Below you’ll find a complete example. You can read more about our Fix language online.
0 commit comments