Skip to content

Instantly share code, notes, and snippets.

@hrj
Last active July 20, 2019 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrj/f9c182f5a57cbc67b90d to your computer and use it in GitHub Desktop.
Save hrj/f9c182f5a57cbc67b90d to your computer and use it in GitHub Desktop.
DBF Show
import net.iryndin.jdbf.reader.*
import net.iryndin.jdbf.core.*
val fis = java.io.FileInputStream(args[0])
val reader = DbfReader(fis)
val md = reader.getMetadata()
val fields = md.getFields()
fields.forEach{f ->
val fieldType = f.getType()
val length =
if(fieldType == DbfFieldTypeEnum.Numeric) {
"%10s.%-10s".format(f.getLength(), f.getNumberOfDecimalPlaces())
} else {
"%10s".format(f.getLength())
}
println("%-20s %10s %s".format(f.getName(), fieldType, length))
}
@hrj
Copy link
Author

hrj commented Apr 20, 2015

How to run this

kotlinc -cp <path to jdbf.jar> -script dbShow.kts <DBF file>

@felipebelluco
Copy link

How did you add the DbfReader as a dependency?

@hrj
Copy link
Author

hrj commented Jul 20, 2019

How did you add the DbfReader as a dependency?

It's been a long time, but I guess adding jdbf.jar to the class path would have done that. That's what the -cp argument is doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment