Read CSV / TSV table
Read a lookup table from an external CSV or TSV file:Groovy: Select all
csv('/path/to/table.tsv')
e.g. use custom series names
Format: Select all
{
def map = csv('/path/to/table.tsv')
n.replace(map)
}
Console Output: Select all
$ cat ~/table.tsv
Deep Space 9 DS9
How I Met Your Mother HIMYM
Read lines of text
Read lines from a text file:Groovy: Select all
lines('/path/to/lines.txt')
e.g. check if a given series name is on the list
Format: Select all
{
def list = lines('/path/to/lines.txt')
n in list ? 'Kids Shows' : 'TV Shows'
}
Console Output: Select all
$ cat ~/lines.txt
Kamikaze Kaitou Jeanne
Sailor Moon
Read XML files
Parse XML file:Groovy: Select all
xml('/path/to/data.xml')
e.g. rename files based on sibling XML files
Format: Select all
{
def i = xml(folder / fn + '.xml')
[i.Series, i.Number, i.Title].join(' - ')
}
xml: Select all
<ComicInfo>
<Title>Ask Not</Title>
<Series>The American Way</Series>
<Number>1</Number>
</ComicInfo>
Parse JSON files
Parse JSON file:Groovy: Select all
json('/path/to/data.json')
Parse HTML pages
Parse HTML page:Groovy: Select all
html('https://www.example.com/')