How to run system commands in DataVerse

Comments

1 comment

  • Avatar
    Adrian Williams

    Hi Shashi,

    You probably want to investigate the use of the Python node in the 'Interfaces and Adaptors' category of the node palette.

    At its most basic you could insert the following at the start of the default script to invoke a system command (in this case for the ipconfig command with an argument:

    import braininfo
    import os

    os.system('ipconfig /all')

    Note that the Python node itself uses the install of Python that is shipped with Dataverse, not the Python install located in your C:\Python27 directory.

    As an alternative to executing an external .py file you may want to consider integrating your logic within the Python node itself. However, I presume you are using one or more Python modules in your script which means that you would need to ensure the appropriate python modules are in the Python node's site-directory.

     

    For a default install the site-directory is located here:

    C:\Program Files\Dataverse\platform\windows-x86-64\python\Lib\site-packages

     

    Any Python packages you want to use will have to be compatible with this version of Python both in terms of the release (2.7) and for the architecture (32-bit).

    Attached is a *very* quick and dirty script that will Extract the text from a specified PDF file and write it into a txt file in the same directory as the source file. The conversion script is not actually integrated into the logic of the node, it has no validation or error handling code and hence is not really suitable for real-world use or supported by Lavastorm. The tabular text is extracted on a one-field-per-line basis so you would have to import and transpose the data (e.g. using other Dataverse nodes) to recreate the tabular data from the PDF file.

    Also attached is the sample file used when putting together the example script (you may have to download it before it viewing it rather than viewing it directly in your browser).

    If you have success with your project you may want to consider sharing your solution with the community.

     

    Regards,

    Adrian

     

     

     

     

    Attached files

    Python_Node_Convert_PDF2TXT_script.txt
    Invoices_Multiple_Months_XLSX.pdf

    0
    Comment actions Permalink

Please sign in to leave a comment.



Powered by Zendesk