Xojo Developer Conference
Join us from 25th to 27th April 2018 in Denver.

Platforms to show: All Mac Windows Linux Cross-Platform

SplitCommaSeparatedValuesMBS(text as string, delimiter as string = ",", quote as string = """") as string()
global method, String, MBS Util Plugin (Util),
Plugin version: 11.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Splits a string with CSV values.
// 1. read a CSV file:

dim file as FolderItem = SpecialFolder.Desktop.Child("test.csv")
dim t as TextInputStream = TextInputStream.open(file)

// use right encoding for your file!
t.Encoding = encodings.MacRoman

while not t.EOF
dim line as string = t.ReadLine
dim items() as string = SplitCommaSeparatedValuesMBS(line)

// process items array

// 2. compare with split:

dim test as string = "Hello,""World,test"",end"

dim a() as string = split(test, ",")
dim b() as string = SplitCommaSeparatedValuesMBS(test, ",")

MsgBox Join(a,EndOfLine)+EndOfLine+EndOfLine+Join(b,EndOfLine)
Notes: This function is better for CSV data than the Split function as it handles quoted text right.

Some examples using this method:

Some FAQ entries about this method:

The items on this page are in the following plugins: MBS Util Plugin.

MBS Xojo Chart Plugins