2 Questions re: Monkeybread

I’m considering buying ’ MBS Util Plugin’ and need to confirm that I can use it on my three machines. I have a current license for Xojo Pro and use it on my desktop at my office, desktop at home, and my laptop that travels with me. I’m one person, but develop on all three machines. Will I be able to use it on all three of my machines, the same as Xojo Pro allows?

The feature that is driving me to purchase ‘MBS Util Plugin’ is ‘SplitCommaSeparatedValuesMBS’. I do a lot of work with TSV and CSV files (that I get from others) and I need to reliably parse them. normally I read them a line at a time, then split on the tabs or commas. With TSV, I have no issues. With CSV, a line having a field with an embedded comma gets trashed.

Example of what I use:
Var f as FolderItem
Var tis as TextInputStream
Var LineFromFile as String
Var ItemsFromLine() as String
~
LineFromFile = tis.ReadLine
ItemsFromLine = Split(LineFromFile,",")

The above obviously fails to account for data that looks like this:

"Apples","Oranges","Pears, Large","Pears, Small","Grapes"

Intsead of:
Apples
Oranges
Pears, Large
Pears, Small
Grapes

After dealing with the double-quotes, I get:
Apples
Oranges
Pears
 Large
Pears
 Small
Grapes

If I’m reading the MBS page right, SplitCommaSeparatedValuesMBS will not split commas inside of double-quotes. Is that correct?

Thanks!

No comment on MBS, but here’s a method that can split that string:

Public Function SplitQuotedCSV(Data As String) As String()
  Dim output() As String
  Dim input As New BinaryStream(Data)
  Dim tmp As String
  Dim quote As Boolean
  Do Until input.EOF
    Dim char As String = input.Read(1)
    Select Case char
    Case ","
      If quote Then
        tmp = tmp + char
      Else
        output.Append(tmp)
        tmp = ""
      End If
      
    Case """"
      quote = Not quote
      
    Else
      tmp = tmp + char
    End Select
  Loop
  If tmp.Trim <> "" Then output.Append(tmp)
  input.Close
  Return output
End Function

Hi Bill.

1.) - Yes. I’m pretty sure an MBS license is per developer, so you can put your license registration into as many of your projects (on as many machines you have Xojo installed) without issue.

2.) - I have no direct experience with that particular MBS class, but you can just download the MBS plugins, put them in your Xojo/Plugins folder (then restart Xojo) and run them without a license, and test the new logic in debug mode.

I think it’s only when you try and build a project with unlicensed MBS plugins that you’ll get a warning message.

That makes it easy to try them out. Good luck.

1 Like

You can also try Norm’s CSV parser:

2 Likes

Thanks for the interest in our plugin.

You can try the plugin before buying without limits. You may see a message box from time to time about a missing license.

Once you get a license, you can use it on multiple computers. Licenses are per developer head count. Companies with multiple developers are expected to pay for each developer.

SplitCommaSeparatedValuesMBS function can handle quotes and should not split on commas within quoted text.

Thanks Christian. I’ll trial it tomorrow.

Assuming the data returned still has a leading and trailing quote, what is the most efficient way to drop those? I’m dealing with CSVs that are rather large, and populating a SQLite database, and don’t desire the quotes at that point.

Mabye you try the example files included with the plugin?

Some examples using this global method:

Some FAQ entries about this method:

Hi Christian,

I sampled the plugin (SplitCommaSeparatedValuesMBS) and found it works for what I need. I have placed an order with you.

One thing I did encounter is that my source data used LineEndings.Windows (CRLF) and that produced an empty row, every other row of output.

0)data
1)empty
2)data
3)empty

For the delimiter I tried all the variations for line endings. It still did it. I may make a sample project if you like?

In any case, a simple workaround was to replace line endings to UNIX after reading in my data, prior to splitting it.

I did try the code suggested earlier in the thread. It was far far slower. My file sizes reach 300MB.

Thanks Bill

The code shared by Andrew reads the data character by character, that’s why it is extremely slow.
It could be highly optimised by processing each line in the text file separately and first checking if the line contains a quote, splitting by comma and re-joining “words” that don’t start with a double-quote.

Anyway, glad you found a better solution with Christian’s plugins, which are great by the way!