Jump to content
UBot Underground

Create Table From File Non-comma Delimiter - Stumped


Recommended Posts

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 2

Data11~Data12

Data21~Data22

Data31~Data32

Data41~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

 

Link to post
Share on other sites

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

  • Like 1
Link to post
Share on other sites

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

Demo 1

 

ui text box("Delimiter"#delimiter)
save to file("{$special folder("Desktop")}\\martinCtest.csv""Data11{#delimiter}Data12
Data21{#delimiter}Data22
Data31{#delimiter}Data32
Data41{#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}Data12
Data21{#delimiter}Data22
Data31{#delimiter}Data32
Data41{#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)

Link to post
Share on other sites

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...

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...