VNA file import fails with empty string values ""
#2574
Description
Hello! Thanks for all your work on gephi.
We recently upgraded our project from gephi-toolkit 0.8 to gephi-toolkit 0.9.6. In doing so one of our tests that previously passed started failing. The test imported a simple VNA file, and nothing changed with that: same test file, same test code. I've pared down the import code to the below and confirmed the issue happens without any of our project's code involved.
This seems like a bug to me, but if I'm missing something that changed between 0.8 and 0.9 that would require a change to our code to keep these imports working, please let me know.
Here is the full.vna
file contents:
*Node data
ID tvar breed spots fur missing
1 true MICE "" white foo
2 false FROGS true "" foo
3 false FROGS true "" foo
*Node properties
ID x y size color shortlabel
1 -355.93912 -114.81057 10.0 153 1
2 -170.28754 214.69585 10.0 153 2
3 526.2267 -99.88528 10.0 153 3
*Tie data
from to strength breed lvar
1 2 1.0 directed-edges 5.0
3 1 10.0 undirected-edges ""
1 3 10.0 undirected-edges ""
Here is the Scala code for the import.
import java.io.{ File, FileReader }
import scala.collection.JavaConverters._
import org.gephi.io.importer.api.ImportController
import org.openide.util.Lookup
object GephiVnaBugPoc {
def main(args: Array[String]) = {
val importController = Lookup.getDefault.lookup(classOf[ImportController])
val file = new File("full.vna")
val reader = new FileReader(file)
val importer = importController.getFileImporter(file)
val container = importController.importFile(reader, importer)
val unloader = container.getUnloader
val report = container.getReport
val nodes = unloader.getNodes
val nodeInfo = nodes.asScala.map( (node) => {
val attributes = node.getColumns.asScala.map( (column) => {
val value = node.getValue(column.getId)
s"(${column.getId} -> $value)"
})
s"${node.getId}: ${attributes.mkString(" ")}"
}).mkString("\n")
println("* Import report:\n")
println(report.getText(true))
println("* Nodes:\n")
println(nodeInfo)
}
}
And here is the output when that is run:
Jul 28, 2022 10:33:45 AM org.netbeans.modules.masterfs.watcher.Watcher getNotifierForPlatform
INFO: Native file watcher is disabled
* Import report:
Node column 'tvar' (String)
Node column 'breed' (String)
Node column 'spots' (String)
Node column 'fur' (String)
Node column 'missing' (String)
Value can't be null
* Nodes:
1: (tvar -> true) (breed -> MICE) (spots -> null) (fur -> null) (missing -> null)
So it appears when the first node line is read 1 true MICE "" white foo
that ""
value is causing a null value to be generated, which is then rejected. This also stops the processing of the nodes, as only that one is imported. I didn't add it to the output, but no edges are imported either.
Possible Solution
I didn't fully explore the gephi code, but it seemed like something might be off with how the regex is used in the ImporterVNA.split()
method.
Your Environment
- Version used: Gephi 0.9.6
- Operating System: I'm running on Ubuntu 20.04 through WSL using Java 17.