V S Posted February 27, 2019 Share Posted February 27, 2019 Hi, I am trying to write a script which creates a data table from one or multiple text files. Any new file or any changes to text file, the data table should be updated/append the lines. The text file is very small and has 4 columns and couple of lines of text. Appreciate any help. Thanks Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted February 27, 2019 Share Posted February 27, 2019 You can use the TextFileDataSource to add a datatable using a text file. https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-a... A sample script would be something as below, from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings readerSettings = TextDataReaderSettings() readerSettings.Separator = "," readerSettings.CultureName = "en-GB" dSource = TextFileDataSource("c:/file.txt",readerSettings) tblfound="false" for table in Document.Data.Tables: if table.Name == "dataFromText": tblfound = "true" if tblfound == "false": Document.Data.Tables.Add("dataFromText",dSource) if tblfound == "true": Document.Data.Tables["dataFromText"].ReplaceData(dSource) Link to comment Share on other sites More sharing options...
V S Posted February 28, 2019 Author Share Posted February 28, 2019 Thanks a lot Shandilya. Using 'TextFileDataSource ' is a great idea and it does work. My only issue is - The text file is in following format - Col1:Val1 Col2:Val2 Col3: Val3 .. and so on. So I want to be able to fetch Col1 value as column name of my Spotfire data table and use 'Val' as values in the column. There could be muliple rows in text file with same columns but different values... any idea how can I do this Thanks for your help. 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