Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Collaborative Coding with Emacs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Data Literacy - RDM
workshops
Collaborative Coding with Emacs
Commits
4434b71b
Commit
4434b71b
authored
1 year ago
by
Jonathan Hartman
Browse files
Options
Downloads
Patches
Plain Diff
started a section on Data Cleaning by porting over the code from the notebook
parent
ad7d6fc8
Branches
Branches containing commit
Tags
v1.10.2
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lia/nfdi-emacs-lia-workshop.lia.md
+93
-0
93 additions, 0 deletions
lia/nfdi-emacs-lia-workshop.lia.md
with
93 additions
and
0 deletions
lia/nfdi-emacs-lia-workshop.lia.md
+
93
−
0
View file @
4434b71b
...
@@ -178,6 +178,99 @@ the letter "Q" followed by a series of numbers...
...
@@ -178,6 +178,99 @@ the letter "Q" followed by a series of numbers...
| Q1205424 | NFDI4Objects |
| Q1205424 | NFDI4Objects |
| Q17575706 | NFDI4Objects |
| Q17575706 | NFDI4Objects |
## Switching Languages
One of the neat things about org-babel is that we can pass seemlessly pass data between languages.
You may recall from the cell that contained our SPARQ query this bit:
`:exports both`
. This ensures
that both the code and the results of that cell are present when the file is exported. For our
specific purpose here, that means that other cells can use the output of this cell as input.
We can specifically ask for the results of a previous cell by referencing the name of that cell.
Our SPARQL cell had the line
`#+NAME: raw-dataset`
, which means we can ask for the result of this
cell by referencing this name as a variable. Let's look at how to do that in the next section.
## Passing Data Between Cells
We'll look at the orb-babel cell first, then at a closer look at the shell command.
```
#+CAPTION: Cleaning the raw data.
#+NAME: clean-dataset
#+BEGIN_SRC sh -n :var input=raw-dataset :colnames yes :exports both
echo "$input" | sed -E '/Q[0-9]+/d'
#+END_SRC
```
## sed and Regex
As a brief explination of the code, we are taking the result of the
`raw-dataset`
cell, and
assigning that value to the variable "$input". We are then echoing that input, but filtering it
using
`sed`
, A Unix utility that can be used for parsing and transforming text.
The
`-E`
switch is telling sed that we are going to use an extended regex expression.
The pattern
`'/Q[0-9]+/d'`
has a few different components:
-
`/`
marks the start of the pattern
-
`Q[0-9]+`
is a regex pattern that says "match lines that contain a ! followed by one or more
digits
-
`/d`
is a sed command that deletes the current pattern space, which in the context of $input
will be the entire line
## Viewing our Results
```
| wLabel | pLabel |
|--------------------------------------------------------------+-------------------|
| Academy of Sciences and Humanities in Hamburg | Text+ |
| Academy of Sciences and Literature Mainz | NFDI4Culture |
| Academy of Sciences and Literature Mainz | NFDI4Memory |
| Academy of Sciences and Literature Mainz | NFDI4Objects |
| Academy of Sciences and Literature Mainz | Text+ |
| Alfred Wegener Institute for Polar and Marine Research | NFDI4Biodiversity |
| Alfred Wegener Institute for Polar and Marine Research | NFDI4DataScience |
| Alfred Wegener Institute for Polar and Marine Research | NFDI4Earth |
| Anthropological Society (Munich) | NFDI4Objects |
| Arachnologische Gesellschaft | NFDI4Biodiversity |
| Arbeitskreis Provenienzforschung e.V. | NFDI4Memory |
| Archivschule Marburg | NFDI4Memory |
| Archäologische Kommission für Niedersachsen | NFDI4Objects |
| Archäologisches Museum Hamburg und Stadtmuseum Harburg | NFDI4Objects |
| Arthistoricum | NFDI4Culture |
| Association for Data-Intensive Radio Astronomy | PUNCH4NFDI |
| Association for Technology and Construction in Agriculture | FAIRAgro |
| Association of German Architects | NFDI4Culture |
| Association of Population Based Cancer Registries in Germany | NFDI4Health |
| Association of states archaeologists | NFDI4Objects |
| BERD@NFDI | Base4NFDI |
| Bach-Archiv Leipzig | NFDI4Culture |
| Bauhaus-Universität Weimar | NFDI4Ing |
| Bavarian Academy of Sciences and Humanities | BERD@NFDI |
| Bavarian Academy of Sciences and Humanities | NFDI4Earth |
| Bavarian Academy of Sciences and Humanities | NFDI4Memory |
| Bavarian Academy of Sciences and Humanities | NFDI4Objects |
| Bavarian Academy of Sciences and Humanities | NFDIxCS |
| Bavarian Academy of Sciences and Humanities | PUNCH4NFDI |
| Bavarian Academy of Sciences and Humanities | Text+ |
| Bavarian Forest National Park | NFDI4Biodiversity |
| Bavarian Natural History Collections | NFDI4Biodiversity |
| Bavarian Natural History Collections | NFDI4Objects |
| Bavarian State Archaeological Collection | NFDI4Objects |
| Bavarian State Archives | FAIRAgro |
| Bavarian State Archives | NFDI4Biodiversity |
| Bavarian State Archives | NFDI4Earth |
| Bavarian State Archives | NFDI4Objects |
| Bavarian State Library | NFDI4Culture |
| Bavarian State Library | NFDI4Memory |
| Bavarian State Research Center for Agriculture | FAIRAgro |
| Beethoven House | NFDI4Culture |
| Beilstein Institute for the Advancement of Chemical Sciences | NFDI4Chem |
| Berlin State Library | Base4NFDI |
| Berlin State Library | NFDI4Memory |
```
# Processing Data
# Processing Data
# Preserving Data
# Preserving Data
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