Created
March 7, 2019 10:59
-
-
Save derms/4d1b4f841415c7029d01d39c57ee93d8 to your computer and use it in GitHub Desktop.
Count Lines in CSV's before MLCP
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
task importSampleData(type: com.marklogic.gradle.task.MlcpTask) { | |
def directory = "./sample-dir/" // can get this from gradle properties | |
//parse csv files | |
doFirst { | |
println "\nSTART: Reading files" | |
def totalLineCount = 0 | |
fileTree(directory).each{ file -> | |
def filename = file.getName() | |
def lineCount = java.nio.file.Files.lines(file.toPath()).count() -1; | |
println "${filename} has ${lineCount} lines (excluding header)" | |
totalLineCount = totalLineCount + lineCount | |
} | |
println "FINISHED: Reading files" | |
println "TOTAL LINE COUNT (excluding headers): ${totalLineCount}\n" | |
} | |
//standard mlcp config | |
classpath = configurations.mlcp | |
command = "IMPORT" | |
port = Integer.parseInt(mlStagingPort) | |
database = mlStagingDbName | |
input_file_path = directory | |
input_file_type = "delimited_text" | |
delimiter = ";" | |
output_collections = "sample,input" | |
output_permissions = "rest-reader,read,rest-writer,update" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment