Repository navigation
Modern String SplitCsvRow
Paul Squires edited this page Oct 19, 2026
·
5 revisions
Home › String Library › String Library › SplitCsvRow
Parses one CSV record into an Array of fields.
SplitCsvRow( s [, delim] )- O(n) — one record through the same cursor SplitCsv uses. The quote-aware Split.
- Returns the same
Array( of T )Split does —Array( of string )for a STRING,Array( of ustring )for a WSTRING or USTRING — so it is a drop-in wherever the fields may be quoted. - An empty result means malformed, on SplitCsv's rule: a well-formed parse always yields at least one field, and an empty record is one empty field.
- Text holding more than one record answers the first record only. The rest is a table, and SplitCsv is what returns tables.
- Where there is nothing to quote it agrees with Split exactly, empty fields included.
- A delimiter that is not exactly one code unit means no delimiter: the whole record comes back as one field.
#import "std/containers"
#import "std/strings"
using strings, containers
dim as Array( of string ) f = SplitCsvRow( !"a,\"b,c\",d" )
print f.Count( ) '' 3 -- the quoted comma did not split anything
print f[ 1 ] '' b,c
'' With nothing quoted it is Split, empty fields and all
dim as Array( of string ) g = SplitCsvRow( "a,,c" )
print g.Count( ) '' 3
print "[" & g[ 1 ] & "]" '' []
'' Empty means malformed -- never a field count of zero on good input
dim as Array( of string ) bad = SplitCsvRow( !"a,\"oops" )
if bad.Count( ) = 0 then print "malformed record"
'' Any single-character delimiter
dim as Array( of string ) tsv = SplitCsvRow( "x" & chr( 9 ) & "y", chr( 9 ) )
print tsv.Count( ) '' 2Library: String Library
Category: String Library
Documented under: The Functions
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing