Read external CSV / TSV / JSON / XML files

All about user-defined episode / movie / file name format expressions
Post Reply
User avatar
rednoah
The Source
Posts: 23346
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Read external CSV / TSV / JSON / XML files

Post by rednoah »

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')
:arrow: See Custom Format Server for usage details and examples.





Parse HTML pages

Parse HTML page:

Groovy: Select all

html('https://www.example.com/')
:arrow: See Custom Page Scraper for usage details and examples.
:idea: Please read the FAQ and How to Request Help.
Post Reply