Skip to content

Instantly share code, notes, and snippets.

@welshstew
Created August 6, 2015 07:11
Show Gist options
  • Save welshstew/2ccff2caac79996d9231 to your computer and use it in GitHub Desktop.
Save welshstew/2ccff2caac79996d9231 to your computer and use it in GitHub Desktop.
print out columns which have linefeeds
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