Skip to content

Instantly share code, notes, and snippets.

View gcko's full-sized avatar
🇹🇼
Working from 🇹🇼

Jared Scott gcko

🇹🇼
Working from 🇹🇼
View GitHub Profile
@mvitaly
mvitaly / Fixed-length-fields.txt.groovy
Last active January 24, 2022 13:22
DataGrip extractor for txt file with fixed length columns
SEPARATOR = "|"
SPACE = " "
CORNER = "+"
LINE = "-"
NEWLINE = System.getProperty("line.separator")
def outRecord(columnLengths, row, separator=SEPARATOR, padding=SPACE) {
OUT.append(separator)
[columnLengths, row].transpose().each { size, value ->
OUT.append(padding + value.padRight(size, padding) + padding + separator)