Created
August 6, 2015 07:11
-
-
Save welshstew/2ccff2caac79996d9231 to your computer and use it in GitHub Desktop.
print out columns which have linefeeds
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 groovy.io.FileType | |
import static com.xlson.groovycsv.CsvParser.parseCsv | |
/** | |
* Created by swinchester on 6/08/15. | |
*/ | |
def dir = new File('/Users/swinchester/') | |
dir.eachFileRecurse (FileType.FILES) { file -> | |
def hasLineFeed = [] | |
if(file.path.endsWith('csv')){ | |
println file.path | |
def csvFile = new File(file.path).text | |
def csvData = parseCsv(csvFile) | |
def columns = null | |
csvData.each { row -> | |
if(columns == null){ | |
columns = row.columns | |
} | |
for(int i = 0; i < row.values.length; i++){ | |
def valString = row.values[i] | |
if(valString.contains(System.getProperty("line.separator"))){ | |
def colName = columns.find { it.value == i }?.key | |
if(!hasLineFeed.contains(colName)){ | |
hasLineFeed.add(colName) | |
} | |
} | |
} | |
} | |
println hasLineFeed | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment