pratikpathak Posted June 24 Share Posted June 24 I have created one template in Spotfire, Based on the name of the csv file i have to apply some transformation. I would like to ask is there any way I can automate this step, it should check the name of the file and then based on these name it should apply transformation. Thankyou and regards, Pratik Pathak Link to comment Share on other sites More sharing options...
barchiel33 Posted June 24 Share Posted June 24 yes, that should be possible although it depends a bit on how you added (or add) the CSVs. I'm not sure the exact code off the top of my head, but you should be able to use Ironpython to iterate over your CSVs (either when using Ironpython to load the CSVs or by iterating over the data sources in the report and checking their type). As you iterate, you can use either an If elif or extract whatever transformation from the file name. Then Ironpython has ways to add/remove/change transformations to data tables. Here are some example scripts that may give you a good starting point: Link to comment Share on other sites More sharing options...
pratikpathak Posted June 25 Author Share Posted June 25 23 hours ago, barchiel33 said: yes, that should be possible although it depends a bit on how you added (or add) the CSVs. I'm not sure the exact code off the top of my head, but you should be able to use Ironpython to iterate over your CSVs (either when using Ironpython to load the CSVs or by iterating over the data sources in the report and checking their type). As you iterate, you can use either an If elif or extract whatever transformation from the file name. Then Ironpython has ways to add/remove/change transformations to data tables. Here are some example scripts that may give you a good starting point: Hi @barchiel33, my csv is loaded in data source panel. I'm still little confused, lemme explain with an example, if in the name of csv file contains "DateFilter" keyword then only it should apply the transformation "[Date] !=01012024", if it does not contain this keyword then this transformation should be skipped. I'm Unsure about how and where to place ironPython script, would you please tell me with a sample code. Link to comment Share on other sites More sharing options...
barchiel33 Posted June 25 Share Posted June 25 Hi @pratikpathak, so you have a set of transformations and in the titles are basically flags indicating which to apply? Something like FebData_DateFilter_ConvertToHours_FactoryFilter.csv? When do you apply the transformations? Ex. Right when you load the data, later when you merge data, etc. etc. Have you used Ironpython before? Link to comment Share on other sites More sharing options...
pratikpathak Posted June 26 Author Share Posted June 26 Hi @barchiel33, thanks for replying, yes the titles (keyword in the name of csv file) are like flag. I have to apply this transformation at time of loading data. i have used little bit of IronPython. Once again, thanks for helping me out. 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