B4A Library [B4X] CSVParser - CSV parser and generator

CSV - comma separated values format.

The various StringUtils libraries include methods for loading and saving CSV files.

However these methods have a few drawbacks:

- They work with files instead of strings. This is especially problematic if the input is not UTF8 encoded.
- As they are implemented inside a native library it is not possible to modify their behavior. Some CSV files are not 100% valid and will not work with these methods.

CSVParser is a class that allows parsing and generating CSV strings:
Dim parser As CSVParser
Dim table As List = parser.Parse(File.ReadString(File.DirAssets, "1.csv"), ",", False)
For Each row() As String In table
   'work with row
Dim s As String = parser.GenerateString(table, ",")
File.WriteString(File.DirApp, "1.csv", s)


  • CSVParser.bas
    2.6 KB · Views: 1,591
Last edited by a moderator: