Created
July 14, 2017 08:52
-
-
Save xlson/dd970f2588f3344011f36ddb31450828 to your computer and use it in GitHub Desktop.
Example of removing blanks in columnNames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spock.lang.Specification | |
class ColumnFixesSpec extends Specification { | |
def csvData = """Name,Last Name,Age | |
Leonard,Gram,33""" | |
def "Removing all blanks from columnNames to make them easier to parse"() { | |
setup: | |
def columnNames = CsvParser.parseCsv(csvData).next().columns.collect { it.key.toString().replaceAll(' ','') } | |
def csv = CsvParser.parseCsv(csvData, columnNames:columnNames) | |
def line = csv.next() | |
expect: | |
line.Name == 'Leonard' | |
line.LastName == 'Gram' | |
line.Age == '33' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment