Example: /Util/Read CSV File

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/Read CSV File


Required plugins for this example: MBS Util Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Read CSV File

This example is the version from Thu, 10th Jan 2018.

Project "Read CSV File.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub NewDocument() dim f as FolderItem = GetOpenFolderItem("") if f<>Nil then OpenDocument f end if End EventHandler
EventHandler Sub OpenDocument(item As FolderItem) ReadCSV item End EventHandler
Sub ReadCSV(file as FolderItem) dim t as TextInputStream = TextInputStream.Open(file) t.Encoding = Encodings.UTF8 // we expect here: UTF-8 // prepare window dim w as new TextWindow dim list as listbox = w.List w.Title = file.DisplayName // read header dim header as string = t.ReadLine dim headerItems() as string = SplitCommaSeparatedValuesMBS(header) dim u as integer = UBound(headerItems) list.ColumnCount = u+1 for i as integer = 0 to u list.Heading(i) = headerItems(i) next // read rows dim lines() as string while not t.EOF dim line as string = t.ReadLine if line.trim.len>0 then // ignore empty lines lines.append line end if wend dim AllLines as string = Join(lines, EndOfLine) dim items() as string = SplitCommaSeparatedValuesMBS(AllLines, "") dim n as integer while n < items.Ubound list.AddRow "" for i as integer = 0 to u list.cell(list.LastIndex, i) = items(n) list.CellHelpTag(list.LastIndex, i) = items(n) n = n + 1 next wend End Sub
End Class
Class TextWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

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


💬 Ask a question or report a problem