Slide 1

Slide 1 text

for data science newcomers Oleg Nenashev January 23, 2023

Slide 2

Slide 2 text

Agenda ● Quick self-intro ● jq introduction ● Small demo

Slide 3

Slide 3 text

> whoami --community @oleg_nenashev oleg-nenashev

Slide 4

Slide 4 text

> whoami --academia “I have a PhD in Design… Hardware Design” Oleg @ Open Source Design Meetup Automation and Industrial Control Automation and Computer Systems Components of computing and control systems Thesis - Reengineering of digital hardware, and embedding test modules and interfaces into devices described by multilevel models BSc - 2009 MSc - 2011 PhD - 2015 Applied Computer Science in Economics Secondary MSc - 2011

Slide 5

Slide 5 text

> whoami --industry Since 2016, Neuchatel 2008 - 2016, Russia

Slide 6

Slide 6 text

Getting started! Source: commitstrip.com/en/2018/08/24/http- headers-ftw/

Slide 7

Slide 7 text

● One of the most popular data formats ● Service REST APIs ● Metadata ● [Un]structured data

Slide 8

Slide 8 text

What is jq? “jq is a lightweight and flexible command-line JSON processor” “jq is like sed for JSON data” stedolan.github.io/jq

Slide 9

Slide 9 text

“jq is like sed for JSON data” Input JSON Resulting JSON ❖ Filtering ❖ Search ❖ Sorting

Slide 10

Slide 10 text

Data Access with jq ● Index slices ● Field slices ● Optional fields support

Slide 11

Slide 11 text

Search with jq ● Selector queries ● Search by value ● Functional processing

Slide 12

Slide 12 text

Advanced jq features Syntax ● Math ● Comparisons ● Variable binding ● Iterators ● Micro-scripting ● Regular expressions Tool ● Stream processing ● Modules / Plugins ● IO operations

Slide 13

Slide 13 text

FAQ: How about YAML? … and other formats

Slide 14

Slide 14 text

YAML Engineering is HOT

Slide 15

Slide 15 text

Working with YAML ● YAML is [almost] like JSON ● Many tools ● yq - a wrapper for YAML ● github.com/mikefarah/yq ● Other formats are supported

Slide 16

Slide 16 text

Getting Started with jq

Slide 17

Slide 17 text

jq - Where to get it? ● Linux - [Any?] package manager ○ sudo apt install jq ● Windows - Chocolatey ○ choco install jq ● Docker - official image ○ docker pull stedolan/jq ● Python - jq binding ○ pip install jq ● VSCode plugins

Slide 18

Slide 18 text

VSCode Plugins Live editing Queries with preview Linting and previews

Slide 19

Slide 19 text

Try out jq online! https://jqplay.org

Slide 20

Slide 20 text

Demo time! Data Analysis with jq

Slide 21

Slide 21 text

Let’s do Big Data! ETH Library library.ethz.ch/en/archiving-and-digitising/o pen-data/interfaces-and-downloads.html Source: https://www.servicemax.com/uk/fsd/2017/11/03/comic-brake-tho ught-big-data-difficult-manage-meet-ginormous-data/

Slide 22

Slide 22 text

Our data ● Let’s look up for Renku publications ● https://daas.library.ethz.ch/rib/v3/search?q=any,contains,%22Renku%22 Source: en.wikipedia.org/wiki/Japanese_poetry#/media/File:' Kokinshu'-_Anthology_of_Classic_Japanese_Poetry _LACMA_M.91.250.332.jpg

Slide 23

Slide 23 text

Query examples cat eth-library-renku.json | jq … ● Selector - '.docs[1]' ● Selector fields - '.docs[].pnx.display.title' ● Entries about data: '.docs[].pnx.display | select(.title[0] | contains("data"))'

Slide 24

Slide 24 text

Learn More ● jq documentation ○ https://stedolan.github.io/jq/ ● jq tutorials ○ Szymon Stepniak: youtube.com/playlist?list=PLKaiHc24qCTSOGkkEpeIMupEmnInqHbbV ○ https://www.baeldung.com/linux/jq-command-json ● yq documentation ○ https://mikefarah.gitbook.io/yq/

Slide 25

Slide 25 text

Contacts: E-mail: [email protected] GitHub: oleg-nenashev Twitter: @oleg_nenashev QUESTIONS?

Slide 26

Slide 26 text

Credits ● All developers of JSON APIs ● Stephen Dolan, jq author ○ https://github.com/stedolan ● Mike Farah, yq author ○ https://github.com/mikefarah ● OpenMoji project ○ https://openmoji.org