CSV +
Premium CSV processing module for high-performance parsing and generation of delimited datasets in BoxLang+ applications.
This module is only available to +/++ subscribers only but can be installed in conjunction with the bx-plus Module with a limited trial.
The BoxLang CSV module provides a comprehensive and modern API for working with CSV (Comma-Separated Values) files in BoxLang. Built on top of Apache Commons CSV, this module offers both traditional BIF-style functions and a powerful fluent API for creating, reading, parsing, and manipulating CSV files.
✨ Key Features
📊 Create & Manipulate - Create new CSV files or work with existing files
🔄 Format Flexibility - Support for custom delimiters, quotes, escapes, and line separators
⚡ Fluent API - Modern, chainable interface for elegant code
🎯 Type Support - Handles strings, numbers, dates, and complex data
📦 Export/Import - Convert to/from JSON, Query, and arrays of structs
🚀 Streaming - Memory-efficient processing for large files with
process()🔍 Filter & Map - Transform data on-the-fly during load operations
filter() map()🎨 Header Support - Automatic header detection and manipulation
🛠️ Configurable - Extensive configuration options for parsing and writing
📦 Installation
Install the module using CommandBox:
box install bx-csv🚀 Quick Start
Here's a taste of what you can do with the fluent API:
💡 Best Practice: We recommend using the fluent
CSV()API directly over the individual BIFs for a more modern, readable, and maintainable codebase.
🎯 Basic Usage
Creating a New CSV File
There are multiple ways to create CSV files: using the fluent API (recommended), traditional BIFs, or static constructors.
Using Fluent API (Recommended) ✨
Using Static Constructors
Writing Data
Setting Headers and Adding Rows
Setting Row Data by Row Number
Reading Data
Loading from File
Loading from String
Loading with Configuration
Saving CSV Files
Exporting and Importing Data
The CSVFile class provides convenient methods for exporting CSV data to various formats and importing data from those formats.
Exporting to JSON
Exporting to Query
Exporting to Array
Exporting to String
Importing from JSON
Importing from Array of Structs
Importing from Query
Round-trip Export/Import Example
🎨 Intermediate Usage
Working with Headers
Custom Delimiters and Quotes
Filtering and Mapping Data
Working with Different Line Separators
Trimming and Space Handling
Handling Empty Lines and Comments
Null String Handling
Quote Modes
🚀 Advanced Usage
Streaming Large Files
For large CSV files that don't fit in memory, use the process() method to stream through rows:
Complex Fluent API Examples
Building a Report from Database Query
Loading, Transforming, and Saving
Processing Multiple Files and Combining
Converting Between Formats
Handling Duplicate Headers
Skip Header Record Configuration
Auto-flush and Trailing Delimiters
Performance Tips
📚 Reference Documentation
For complete API documentation and detailed method references:
CSV BIF Reference - Complete documentation for the
CSV()functionFluent API Reference - Complete list of all chainable methods
Reference Overview - Browse all available references
🤝 Support & Community
📖 BoxLang Documentation - Official language documentation
💬 Community Slack - Get help from the community
🐛 Issue Tracker - Report bugs and request features
📧 Professional Support - Commercial support options
Last updated
Was this helpful?
