Hi all,
I don't find the way to import a gexf model from a String instead of from a File.
The class ImportController does not seem to expose such a method, is there any other class/method I could use for this purpose?
Thanks in advance,
Pablo
[FIXED] Importing from String instead of File
- mbastian
- Gephi Architect
- Posts:728
- Joined:10 Dec 2009 10:11
- Location:San Francisco, CA [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Re: Importing from String instead of File
Import controller can import from InputStream and Reader, in the same way than files. However, it can't automatically guess what format you are using, as there is no file extension, so you have to provide the appropriate importer. The GEXF importer can simply be retrieved using the getFileImporter() method.
Code: Select all
ImportController importController = Lookup.getDefault().lookup(ImportController.class);
String str = ...
StringReader reader = new StringReader(str);
Container c = importController.importFile(reader, importController.getFileImporter("gexf"));
Re: Importing from String instead of File
Ok, thanks a lot.
Pablo
Pablo
Re: Importing from String instead of File
Hi again,
I just tried your piece of code and the statement:
returns null,
why's that?
I'm using version 0.7.2014
Cheers,
Pablo
I just tried your piece of code and the statement:
Code: Select all
importController.getFileImporter("gexf")
why's that?
I'm using version 0.7.2014
Cheers,
Pablo
- mbastian
- Gephi Architect
- Posts:728
- Joined:10 Dec 2009 10:11
- Location:San Francisco, CA [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Re: Importing from String instead of File
That should work, but I looked at the code we are actually checking for the extension, so do that
and it should work. I will report a bug, as having both matching is expected.
Code: Select all
importController.getFileImporter(".gexf")
Re: Importing from String instead of File
Hi Bastian,
I just tried that fix and it works fine now, thanks
Pablo
I just tried that fix and it works fine now, thanks
Pablo