Martin C 6 Posted March 23, 2014 Report Share Posted March 23, 2014 I am trying to create a table from a CSV file that contains "~" as the delimiter as opposed to the standard ",". Ideally I would just use the "Create Table from File" and specify the delimiter. I know I can change the BOT properties to change the delimiter globally, but I have several CSV files and they use a multitude of delimiter characters. I have tried to use Lists that seem to allow the delimiter to be set programatically, but I am a little stumped as to how I get the data into a table so the data is in a useable format. The CSV file contains two columns Column 1 ~ Column 2Data11~Data12Data21~Data22Data31~Data32Data41~Data42 Is there a simple (or complicated) trick to getting this into a table format? Is it just me or wouldn't it be a major benefit to everyone to be able to specify the delimiter when using the create table from file command? Any assistance/guidance would be much appreciated. Martin Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted March 23, 2014 Report Share Posted March 23, 2014 couple ways to d it 1. in UBS there are File, Edit, View, Bot, Tools etc at top left. press on BOT then you can change the default from , to whatever you want 2. in certain nodes you can set the delimiter as well like $list from text TC 1 Quote Link to post Share on other sites
Martin C 6 Posted March 23, 2014 Author Report Share Posted March 23, 2014 Thanks Traffik Cop, the problem I am having is that it doesn't allow me to change the delimiter dynamically within the procedure, (I have some csv files that have commas, some that have other delimiters), the problem with the list approach is I would like the information in a table for easier processing later and converting lists to a table doesn't appear to be that straight forward. I have now achieved what I am after by using a convoluted loop that uses replace regular expression, I was hoping that there was a more simple way. Martin Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted March 24, 2014 Report Share Posted March 24, 2014 have you tried the dictionary plugin? its free Quote Link to post Share on other sites
Martin C 6 Posted March 24, 2014 Author Report Share Posted March 24, 2014 have you tried the dictionary plugin? its free Unless I am looking at the wrong plugin (Local Dictionary), that seems to be related to storing local variables not creating tables from CSV files. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted March 25, 2014 Report Share Posted March 25, 2014 It stores local list and local tables as well....there was an update recently If you ever wanna multi-thread this will help a ton. I think it has what you are looking for... Quote Link to post Share on other sites
the_way 52 Posted March 25, 2014 Report Share Posted March 25, 2014 I built a custom function for this already, and the best way i could find was as you say, use a loop to replace and create a second table. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted March 26, 2014 Report Share Posted March 26, 2014 Demo 1 ui text box("Delimiter", #delimiter)save to file("{$special folder("Desktop")}\\martinCtest.csv", "Data11{#delimiter}Data12Data21{#delimiter}Data22Data31{#delimiter}Data32Data41{#delimiter}Data42")comment("^^^ for demo")save to file("{$special folder("Desktop")}\\martinCtest.csv", $replace regular expression($read file("{$special folder("Desktop")}\\martinCtest.csv"), "@|\\.|\\*|\\^|~", ","))clear table(&MB2)create table from file("{$special folder("Desktop")}\\martinCtest.csv", &MB2) to file("{$special folder("Desktop")}\\martinCtest.csv", $replace($read file("{$special folder("Desktop")}\\martinCtest.csv"), ",", "~")) Dictionary demo2 ui text box("Delimiter", #delimiter)save to file("{$special folder("Desktop")}\\martinCtest.csv", "Data11{#delimiter}Data12Data21{#delimiter}Data22Data31{#delimiter}Data32Data41{#delimiter}Data42")save to file("{$special folder("Desktop")}\\martinCtest.csv", $replace regular expression($read file("{$special folder("Desktop")}\\martinCtest.csv"), "@|\\.|\\*|\\^|~", ","))plugin command("LocalDictionary.dll", "init local table")plugin command("LocalDictionary.dll", "local table from file", "MC", "{$special folder("Desktop")}\\martinCtest.csv", ",")set(#columns, $plugin function("LocalDictionary.dll", "$local table total columns", "MC"), "Global")ui stat monitor("column: ", #columns) Quote Link to post Share on other sites
mamica 10 Posted March 26, 2014 Report Share Posted March 26, 2014 get notepad++, open csv and change your delimiter to whatever u want, or use openoffice and manually set up your tables and save them with new delimiter... Quote Link to post Share on other sites
Martin C 6 Posted March 27, 2014 Author Report Share Posted March 27, 2014 Thanks for all the suggestions guys, in this particular case I think it is going to be easier for me to change the code in the non-Ubot application that generates the csv files. However, the Local Dictionary plug-in does looks awesome and I can see how I can use that in other areas so thanks Traffik Kop for putting me on to that. I can't help thinking though that it would be handy if the Create from Table command allowed for a delimiter to be specified at run time, it just seems daft to me that it would be a global setup parameter. 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.