Groovy web console

subscribe to the feed Subscribe
to this
site
a-la-spock-tabular-custom (via #groovywebconsole)
tweet this snippet Tweet
this
script

a-la-spock-tabular-custom

Published 1 week ago by Dani
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
tabular_data =
"""
id      | original               | normalizado             | tipoid | etiqueta | otroid | semantica             | otracosa | parrafo
233120  | materia                | Materia                 |  670   | NOMBRE   |        | NOMBRE                |          | 0
658     |                        | S?BOLO                 |  2652  | NOMBRE   |        | ?s?bolo?             |          | 0
219786  | delito de homicidio    | Delito de homicidio     |  670   | NOMBRE   |        | ?Delito de Homicidio? |          | 0
"""

def tabular_to_km(s) {
 s.trim().split(/\n/).collect({it.split(/\|/).collect({it.trim()}).join('~')})[1..-1].join('\\\n')
}

tabular_to_km(tabular_data)