Mathieu Canto Posted February 25, 2019 Share Posted February 25, 2019 I have defined a data function in the TERR Console. This function intends to import one csv file into a data table in Spotfire, and it is working like a charm. I have two csv files between which I want to be able to switch from a drop down property control (named 'dropSourceChoice'). 2 input fields property controls ('inpPath1' and 'inpPath2') are also defined for the user to input the filepath corresponding to 'source1' file and 'source2' file. Except for the case where I directly input the file path in the 'expression' column of the drop down property control, I did not found a way to link those values to the 2 input fields value... NOTA : I am using SPOTFIRE 10 EDIT 1 : I enclosed a zip file with : one dxp and its source files. EDIT 2 : (test_sourceuserchoice_v1.0.1.dxp) Link to comment Share on other sites More sharing options...
Gaia Paolini Posted February 25, 2019 Share Posted February 25, 2019 Hi from your question I am not 100% sure of where the problem appears. Assuming it is the data function that does not recognise the path, it could be because R/TERR does not understand a path with back slashes, such as what you would get by directly pasting a path from your computer. In order to turn it into a recognisable format, once within the data function, you need to turn the back slashes into forward slashes. This R/TERR code worked for me in the past: before using the variable 'mypath': mypath = gsub("\\", "/", mypath) If this is not the issue, or does not solve it, please upload a sample dxp. Gaia Link to comment Share on other sites More sharing options...
Mathieu Canto Posted February 25, 2019 Author Share Posted February 25, 2019 I figured that this may have been a problem.That's why I tried different solutions involving a kind of manipulation of slashes (both front and back), to see if it may have an influence on the result...seems like I could not find a way to make it work as is...but I may have been implementing it the wrong way... I enclosed a directory with just enough to test this situation. Hope it could help to make my situation clearer, and hopefully, help someone to find a solution to my expectations. Link to comment Share on other sites More sharing options...
Gaia Paolini Posted February 25, 2019 Share Posted February 25, 2019 Hi I am attaching a version, that works for me. There were so many attempts in your code I needed to cut down the choice. Essentially, it worked, but not first time, I kind of needed to start from scratch. I wonder if you got caught in creating different data tables, maybe early failed attempts. If you create data tables on the fly you need to make sure they all have the same column structures. Also it may create a problem if you delete some columns or the entire output data table and then try to create one with the same name from a data function. I added a couple of lines to your code, so that if the file does not exist, it still returns an empty data table with the same structure (column names and types). Let me know if it works Gaia Link to comment Share on other sites More sharing options...
Mathieu Canto Posted February 25, 2019 Author Share Posted February 25, 2019 Alright. My problem is more on the communication between the drop down list and the input field. I started back from your file and, if using the input field value as an input value in the TERR Data Function, it works perfectly. But I just can't seem to make it work if the TERR Data Function input file path is wired on the drop down property control value (this value being linked, through an expression, to the input field property control, where the csv file path is supposedly inputed by the user). If I may try to sum up my requirements, it would be: 1 - User inputs csv file path in input field 2 - User select the source file through the drop down property control 3 - the property control value is used as input parameter in TERR Data Function 4 - the TERR Data Function output table is displayed in a data table Do not hesitate to ask for any additional information. Thanks in advance...by the way ;-) Link to comment Share on other sites More sharing options...
Gaia Paolini Posted February 25, 2019 Share Posted February 25, 2019 I see what you mean. If you save the image and then load it in RStudio, you see that the value of the dropSourceChoice that goes into the data function is not properly evaluated:it is either"DocumentProperty("inpPath2)" or"'${inpPath2}'" which is no good to you. I don't know why that is. I can only suggest a slightly different logic. See attached file. You need to specify the name of the folder in the input field, this triggers a function that puts all the files found in that folder into a new table that you can then display in a drop-down list. Once you select the file, the old data function (slightly changed to paste folder and file name) then works. Gaia Link to comment Share on other sites More sharing options...
Mathieu Canto Posted February 26, 2019 Author Share Posted February 26, 2019 Thanks for your answers : it has raised interesting information/example for me.In my everyday work, I am facing people that keeps reformulating their question every time I come to them with an answer, because they realize that their initial question wasn't clear enough...So...sorry for being a pain but...in order to be clearer and more accurate, I have to reformulate my question : How could I used a document property value in the 'Expression' field of a drop down property control definition Link to comment Share on other sites More sharing options...
Gaia Paolini Posted February 28, 2019 Share Posted February 28, 2019 Hi I don't think it is possible to evaluate expressions within a drop down. Gaia Link to comment Share on other sites More sharing options...
Mathieu Canto Posted February 28, 2019 Author Share Posted February 28, 2019 Well...Thanks for all your help. I guess I'll just find a way around, using some of the tricks you've advised. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now