Class OpenCsv

java.lang.Object
cloud.opencode.base.csv.OpenCsv

public final class OpenCsv extends Object
OpenCsv - Unified CSV Processing Facade OpenCsv - 统一CSV处理门面

This is the primary entry point for all CSV operations in the OpenCode CSV library. Provides a comprehensive static API for parsing, writing, binding, streaming, diffing, and validating CSV data. All methods delegate to specialized internal components.

这是OpenCode CSV库中所有CSV操作的主要入口点。提供全面的静态API用于解析、写入、绑定、 流处理、差异比较和验证CSV数据。所有方法委托给专门的内部组件。

Features | 主要功能:

  • RFC 4180 compliant parsing and writing - 符合RFC 4180的解析和写入
  • Multiple input/output sources (String, Path, Stream, Reader/Writer) - 多种输入/输出源
  • Object binding for Records and POJOs - Record和POJO的对象绑定
  • Streaming read/write for large files - 大文件的流式读写
  • CSV document diff/change detection - CSV文档差异/变更检测
  • Validation and utility methods - 验证和工具方法

Usage Examples | 使用示例:

// Parse CSV string
CsvDocument doc = OpenCsv.parse("name,age\nAlice,30\nBob,25");

// Parse CSV file
CsvDocument doc = OpenCsv.parseFile(Path.of("data.csv"));

// Bind to objects
List<Person> people = OpenCsv.bind("name,age\nAlice,30", Person.class);

// Write CSV
String csv = OpenCsv.dump(doc);
OpenCsv.writeFile(doc, Path.of("output.csv"));

// Compare documents
List<CsvChange> changes = OpenCsv.diff(original, modified);

// Streaming
try (CsvReader reader = OpenCsv.reader(path)) {
    reader.stream().forEach(row -> process(row));
}

Security | 安全性:

  • Thread-safe: Yes (stateless facade) - 线程安全: 是(无状态门面)
  • Null-safe: Yes (validates all inputs) - 空值安全: 是(验证所有输入)
  • DoS protection: Configurable row/column/field limits - DoS保护: 可配置的行/列/字段限制
  • Formula injection protection via CsvConfig - 通过CsvConfig的公式注入保护
Since:
JDK 25, opencode-base-csv V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> List<T>
    bind(CsvDocument doc, Class<T> type)
    Binds CSV document rows to objects 将CSV文档行绑定到对象
    static <T> List<T>
    bind(String csv, Class<T> type)
    Parses a CSV string and binds rows to objects using default configuration 使用默认配置解析CSV字符串并将行绑定到对象
    static <T> List<T>
    bind(String csv, Class<T> type, CsvConfig config)
    Parses a CSV string and binds rows to objects with the specified configuration 使用指定配置解析CSV字符串并将行绑定到对象
    static <T> List<T>
    bindFile(Path file, Class<T> type)
    Parses a CSV file and binds rows to objects using default configuration 使用默认配置解析CSV文件并将行绑定到对象
    static <T> List<T>
    bindFile(Path file, Class<T> type, CsvConfig config)
    Parses a CSV file and binds rows to objects with the specified configuration 使用指定配置解析CSV文件并将行绑定到对象
    Creates a new CSV document builder 创建新的CSV文档构建器
    Concatenates multiple CSV documents vertically (appends rows) 纵向连接多个CSV文档(追加行)
    Creates a new CSV configuration builder 创建新的CSV配置构建器
    static List<CsvChange>
    diff(CsvDocument original, CsvDocument modified)
    Computes differences between two CSV documents 计算两个CSV文档之间的差异
    static List<CsvChange>
    diffByKey(CsvDocument original, CsvDocument modified, String keyColumn)
    Computes differences using a key column for row matching 使用键列进行行匹配来计算差异
    static String
    Formats a CSV document to a string using default configuration 使用默认配置将CSV文档格式化为字符串
    static String
    dump(CsvDocument doc, CsvConfig config)
    Formats a CSV document to a string with the specified configuration 使用指定配置将CSV文档格式化为字符串
    static <T> String
    dumpObjects(Collection<T> objects, Class<T> type)
    Converts objects to a CSV string using default configuration 使用默认配置将对象转换为CSV字符串
    static <T> String
    dumpObjects(Collection<T> objects, Class<T> type, CsvConfig config)
    Converts objects to a CSV string with the specified configuration 使用指定配置将对象转换为CSV字符串
    static <T> CsvDocument
    fromObjects(Collection<T> objects, Class<T> type)
    Converts a collection of objects to a CSV document 将对象集合转换为CSV文档
    static List<String>
    Extracts headers from a CSV string using default configuration 使用默认配置从CSV字符串提取标题
    static List<String>
    headers(String csv, CsvConfig config)
    Extracts headers from a CSV string with the specified configuration 使用指定配置从CSV字符串提取标题
    innerJoin(CsvDocument left, CsvDocument right, String keyColumn)
    Joins two CSV documents using inner join on a key column 使用内连接在键列上连接两个CSV文档
    static boolean
    Checks if a string is valid CSV 检查字符串是否为有效的CSV
    leftJoin(CsvDocument left, CsvDocument right, String keyColumn)
    Joins two CSV documents using left join on a key column 使用左连接在键列上连接两个CSV文档
    Parses CSV data from an input stream using default configuration 使用默认配置从输入流解析CSV数据
    parse(InputStream input, CsvConfig config)
    Parses CSV data from an input stream with the specified configuration 使用指定配置从输入流解析CSV数据
    parse(Reader reader)
    Parses CSV data from a reader using default configuration 使用默认配置从Reader解析CSV数据
    parse(Reader reader, CsvConfig config)
    Parses CSV data from a reader with the specified configuration 使用指定配置从Reader解析CSV数据
    Parses a CSV string into a document using default configuration 使用默认配置将CSV字符串解析为文档
    parse(String csv, CsvConfig config)
    Parses a CSV string into a document with the specified configuration 使用指定配置将CSV字符串解析为文档
    Parses a CSV file using default configuration 使用默认配置解析CSV文件
    parseFile(Path file, CsvConfig config)
    Parses a CSV file with the specified configuration 使用指定配置解析CSV文件
    parseFile(Path file, Charset charset)
    Parses a CSV file with the specified charset and default configuration 使用指定字符集和默认配置解析CSV文件
    static CsvQuery
    Creates a fluent query from a CSV document 从CSV文档创建流式查询
    static CsvReader
    Creates a streaming CSV reader from an input stream using default configuration 使用默认配置从输入流创建流式CSV读取器
    static CsvReader
    reader(InputStream input, CsvConfig config)
    Creates a streaming CSV reader from an input stream with configuration 使用配置从输入流创建流式CSV读取器
    static CsvReader
    reader(Reader reader)
    Creates a streaming CSV reader from a reader using default configuration 使用默认配置从Reader创建流式CSV读取器
    static CsvReader
    reader(Reader reader, CsvConfig config)
    Creates a streaming CSV reader from a reader with configuration 使用配置从Reader创建流式CSV读取器
    static CsvReader
    reader(Path file)
    Creates a streaming CSV reader from a file using default configuration 使用默认配置从文件创建流式CSV读取器
    static CsvReader
    reader(Path file, CsvConfig config)
    Creates a streaming CSV reader from a file with configuration 使用配置从文件创建流式CSV读取器
    static int
    Counts the number of data rows in a CSV string (excluding header) 计算CSV字符串中的数据行数(不含标题行)
    split(CsvDocument doc, int maxRows)
    Splits a CSV document into chunks of the specified size 将CSV文档按指定大小分割为块
    stats(CsvDocument doc, String column)
    Computes summary statistics for a column 计算列的摘要统计信息
    Creates a fluent transformation pipeline from a CSV document 从CSV文档创建流式转换管道
    Creates a new CSV validator builder 创建新的CSV校验器构建器
    static void
    Writes a CSV document to an output stream using default configuration 使用默认配置将CSV文档写入输出流
    static void
    write(CsvDocument doc, OutputStream output, CsvConfig config)
    Writes a CSV document to an output stream with the specified configuration 使用指定配置将CSV文档写入输出流
    static void
    write(CsvDocument doc, Writer writer)
    Writes a CSV document to a writer using default configuration 使用默认配置将CSV文档写入Writer
    static void
    write(CsvDocument doc, Writer writer, CsvConfig config)
    Writes a CSV document to a writer with the specified configuration 使用指定配置将CSV文档写入Writer
    static void
    Writes a CSV document to a file using default configuration 使用默认配置将CSV文档写入文件
    static void
    writeFile(CsvDocument doc, Path file, CsvConfig config)
    Writes a CSV document to a file with the specified configuration 使用指定配置将CSV文档写入文件
    static CsvWriter
    Creates a streaming CSV writer to an output stream using default configuration 使用默认配置创建到输出流的流式CSV写入器
    static CsvWriter
    writer(OutputStream output, CsvConfig config)
    Creates a streaming CSV writer to an output stream with configuration 使用配置创建到输出流的流式CSV写入器
    static CsvWriter
    writer(Writer writer)
    Creates a streaming CSV writer to a writer using default configuration 使用默认配置创建到Writer的流式CSV写入器
    static CsvWriter
    writer(Writer writer, CsvConfig config)
    Creates a streaming CSV writer to a writer with configuration 使用配置创建到Writer的流式CSV写入器
    static CsvWriter
    writer(Path file)
    Creates a streaming CSV writer to a file using default configuration 使用默认配置创建到文件的流式CSV写入器
    static CsvWriter
    writer(Path file, CsvConfig config)
    Creates a streaming CSV writer to a file with configuration 使用配置创建到文件的流式CSV写入器

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static CsvDocument parse(String csv)
      Parses a CSV string into a document using default configuration 使用默认配置将CSV字符串解析为文档
      Parameters:
      csv - the CSV string | CSV字符串
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • parse

      public static CsvDocument parse(String csv, CsvConfig config)
      Parses a CSV string into a document with the specified configuration 使用指定配置将CSV字符串解析为文档
      Parameters:
      csv - the CSV string | CSV字符串
      config - the CSV configuration | CSV配置
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • parseFile

      public static CsvDocument parseFile(Path file)
      Parses a CSV file using default configuration 使用默认配置解析CSV文件
      Parameters:
      file - the file path | 文件路径
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing or I/O fails | 如果解析或I/O失败
    • parseFile

      public static CsvDocument parseFile(Path file, CsvConfig config)
      Parses a CSV file with the specified configuration 使用指定配置解析CSV文件
      Parameters:
      file - the file path | 文件路径
      config - the CSV configuration | CSV配置
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing or I/O fails | 如果解析或I/O失败
    • parseFile

      public static CsvDocument parseFile(Path file, Charset charset)
      Parses a CSV file with the specified charset and default configuration 使用指定字符集和默认配置解析CSV文件
      Parameters:
      file - the file path | 文件路径
      charset - the character set | 字符集
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing or I/O fails | 如果解析或I/O失败
    • parse

      public static CsvDocument parse(InputStream input)
      Parses CSV data from an input stream using default configuration 使用默认配置从输入流解析CSV数据
      Parameters:
      input - the input stream | 输入流
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • parse

      public static CsvDocument parse(InputStream input, CsvConfig config)
      Parses CSV data from an input stream with the specified configuration 使用指定配置从输入流解析CSV数据
      Parameters:
      input - the input stream | 输入流
      config - the CSV configuration | CSV配置
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • parse

      public static CsvDocument parse(Reader reader)
      Parses CSV data from a reader using default configuration 使用默认配置从Reader解析CSV数据
      Parameters:
      reader - the reader | 读取器
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • parse

      public static CsvDocument parse(Reader reader, CsvConfig config)
      Parses CSV data from a reader with the specified configuration 使用指定配置从Reader解析CSV数据
      Parameters:
      reader - the reader | 读取器
      config - the CSV configuration | CSV配置
      Returns:
      the parsed document | 解析后的文档
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • dump

      public static String dump(CsvDocument doc)
      Formats a CSV document to a string using default configuration 使用默认配置将CSV文档格式化为字符串
      Parameters:
      doc - the CSV document | CSV文档
      Returns:
      the CSV string | CSV字符串
      Throws:
      OpenCsvException - if formatting fails | 如果格式化失败
    • dump

      public static String dump(CsvDocument doc, CsvConfig config)
      Formats a CSV document to a string with the specified configuration 使用指定配置将CSV文档格式化为字符串
      Parameters:
      doc - the CSV document | CSV文档
      config - the CSV configuration | CSV配置
      Returns:
      the CSV string | CSV字符串
      Throws:
      OpenCsvException - if formatting fails | 如果格式化失败
    • writeFile

      public static void writeFile(CsvDocument doc, Path file)
      Writes a CSV document to a file using default configuration 使用默认配置将CSV文档写入文件
      Parameters:
      doc - the CSV document | CSV文档
      file - the file path | 文件路径
      Throws:
      OpenCsvException - if writing or I/O fails | 如果写入或I/O失败
    • writeFile

      public static void writeFile(CsvDocument doc, Path file, CsvConfig config)
      Writes a CSV document to a file with the specified configuration 使用指定配置将CSV文档写入文件
      Parameters:
      doc - the CSV document | CSV文档
      file - the file path | 文件路径
      config - the CSV configuration | CSV配置
      Throws:
      OpenCsvException - if writing or I/O fails | 如果写入或I/O失败
    • write

      public static void write(CsvDocument doc, OutputStream output)
      Writes a CSV document to an output stream using default configuration 使用默认配置将CSV文档写入输出流
      Parameters:
      doc - the CSV document | CSV文档
      output - the output stream | 输出流
      Throws:
      OpenCsvException - if writing fails | 如果写入失败
    • write

      public static void write(CsvDocument doc, OutputStream output, CsvConfig config)
      Writes a CSV document to an output stream with the specified configuration 使用指定配置将CSV文档写入输出流
      Parameters:
      doc - the CSV document | CSV文档
      output - the output stream | 输出流
      config - the CSV configuration | CSV配置
      Throws:
      OpenCsvException - if writing fails | 如果写入失败
    • write

      public static void write(CsvDocument doc, Writer writer)
      Writes a CSV document to a writer using default configuration 使用默认配置将CSV文档写入Writer
      Parameters:
      doc - the CSV document | CSV文档
      writer - the writer | 写入器
      Throws:
      OpenCsvException - if writing fails | 如果写入失败
    • write

      public static void write(CsvDocument doc, Writer writer, CsvConfig config)
      Writes a CSV document to a writer with the specified configuration 使用指定配置将CSV文档写入Writer
      Parameters:
      doc - the CSV document | CSV文档
      writer - the writer | 写入器
      config - the CSV configuration | CSV配置
      Throws:
      OpenCsvException - if writing fails | 如果写入失败
    • bind

      public static <T> List<T> bind(String csv, Class<T> type)
      Parses a CSV string and binds rows to objects using default configuration 使用默认配置解析CSV字符串并将行绑定到对象
      Type Parameters:
      T - the target type | 目标类型
      Parameters:
      csv - the CSV string | CSV字符串
      type - the target type | 目标类型
      Returns:
      list of bound objects | 绑定的对象列表
      Throws:
      OpenCsvException - if parsing or binding fails | 如果解析或绑定失败
    • bind

      public static <T> List<T> bind(String csv, Class<T> type, CsvConfig config)
      Parses a CSV string and binds rows to objects with the specified configuration 使用指定配置解析CSV字符串并将行绑定到对象
      Type Parameters:
      T - the target type | 目标类型
      Parameters:
      csv - the CSV string | CSV字符串
      type - the target type | 目标类型
      config - the CSV configuration | CSV配置
      Returns:
      list of bound objects | 绑定的对象列表
      Throws:
      OpenCsvException - if parsing or binding fails | 如果解析或绑定失败
    • bind

      public static <T> List<T> bind(CsvDocument doc, Class<T> type)
      Binds CSV document rows to objects 将CSV文档行绑定到对象
      Type Parameters:
      T - the target type | 目标类型
      Parameters:
      doc - the CSV document | CSV文档
      type - the target type | 目标类型
      Returns:
      list of bound objects | 绑定的对象列表
      Throws:
      OpenCsvException - if binding fails | 如果绑定失败
    • bindFile

      public static <T> List<T> bindFile(Path file, Class<T> type)
      Parses a CSV file and binds rows to objects using default configuration 使用默认配置解析CSV文件并将行绑定到对象
      Type Parameters:
      T - the target type | 目标类型
      Parameters:
      file - the file path | 文件路径
      type - the target type | 目标类型
      Returns:
      list of bound objects | 绑定的对象列表
      Throws:
      OpenCsvException - if parsing, I/O, or binding fails | 如果解析、I/O或绑定失败
    • bindFile

      public static <T> List<T> bindFile(Path file, Class<T> type, CsvConfig config)
      Parses a CSV file and binds rows to objects with the specified configuration 使用指定配置解析CSV文件并将行绑定到对象
      Type Parameters:
      T - the target type | 目标类型
      Parameters:
      file - the file path | 文件路径
      type - the target type | 目标类型
      config - the CSV configuration | CSV配置
      Returns:
      list of bound objects | 绑定的对象列表
      Throws:
      OpenCsvException - if parsing, I/O, or binding fails | 如果解析、I/O或绑定失败
    • fromObjects

      public static <T> CsvDocument fromObjects(Collection<T> objects, Class<T> type)
      Converts a collection of objects to a CSV document 将对象集合转换为CSV文档
      Type Parameters:
      T - the object type | 对象类型
      Parameters:
      objects - the objects | 对象集合
      type - the object type | 对象类型
      Returns:
      the CSV document | CSV文档
      Throws:
      OpenCsvException - if conversion fails | 如果转换失败
    • dumpObjects

      public static <T> String dumpObjects(Collection<T> objects, Class<T> type)
      Converts objects to a CSV string using default configuration 使用默认配置将对象转换为CSV字符串
      Type Parameters:
      T - the object type | 对象类型
      Parameters:
      objects - the objects | 对象集合
      type - the object type | 对象类型
      Returns:
      the CSV string | CSV字符串
      Throws:
      OpenCsvException - if conversion fails | 如果转换失败
    • dumpObjects

      public static <T> String dumpObjects(Collection<T> objects, Class<T> type, CsvConfig config)
      Converts objects to a CSV string with the specified configuration 使用指定配置将对象转换为CSV字符串
      Type Parameters:
      T - the object type | 对象类型
      Parameters:
      objects - the objects | 对象集合
      type - the object type | 对象类型
      config - the CSV configuration | CSV配置
      Returns:
      the CSV string | CSV字符串
      Throws:
      OpenCsvException - if conversion fails | 如果转换失败
    • reader

      public static CsvReader reader(InputStream input)
      Creates a streaming CSV reader from an input stream using default configuration 使用默认配置从输入流创建流式CSV读取器
      Parameters:
      input - the input stream | 输入流
      Returns:
      the CSV reader | CSV读取器
    • reader

      public static CsvReader reader(InputStream input, CsvConfig config)
      Creates a streaming CSV reader from an input stream with configuration 使用配置从输入流创建流式CSV读取器
      Parameters:
      input - the input stream | 输入流
      config - the CSV configuration | CSV配置
      Returns:
      the CSV reader | CSV读取器
    • reader

      public static CsvReader reader(Reader reader)
      Creates a streaming CSV reader from a reader using default configuration 使用默认配置从Reader创建流式CSV读取器
      Parameters:
      reader - the reader | 读取器
      Returns:
      the CSV reader | CSV读取器
    • reader

      public static CsvReader reader(Reader reader, CsvConfig config)
      Creates a streaming CSV reader from a reader with configuration 使用配置从Reader创建流式CSV读取器
      Parameters:
      reader - the reader | 读取器
      config - the CSV configuration | CSV配置
      Returns:
      the CSV reader | CSV读取器
    • reader

      public static CsvReader reader(Path file)
      Creates a streaming CSV reader from a file using default configuration 使用默认配置从文件创建流式CSV读取器
      Parameters:
      file - the file path | 文件路径
      Returns:
      the CSV reader | CSV读取器
      Throws:
      OpenCsvException - if the file cannot be opened | 如果无法打开文件
    • reader

      public static CsvReader reader(Path file, CsvConfig config)
      Creates a streaming CSV reader from a file with configuration 使用配置从文件创建流式CSV读取器
      Parameters:
      file - the file path | 文件路径
      config - the CSV configuration | CSV配置
      Returns:
      the CSV reader | CSV读取器
      Throws:
      OpenCsvException - if the file cannot be opened | 如果无法打开文件
    • writer

      public static CsvWriter writer(OutputStream output)
      Creates a streaming CSV writer to an output stream using default configuration 使用默认配置创建到输出流的流式CSV写入器
      Parameters:
      output - the output stream | 输出流
      Returns:
      the CSV writer | CSV写入器
    • writer

      public static CsvWriter writer(OutputStream output, CsvConfig config)
      Creates a streaming CSV writer to an output stream with configuration 使用配置创建到输出流的流式CSV写入器
      Parameters:
      output - the output stream | 输出流
      config - the CSV configuration | CSV配置
      Returns:
      the CSV writer | CSV写入器
    • writer

      public static CsvWriter writer(Writer writer)
      Creates a streaming CSV writer to a writer using default configuration 使用默认配置创建到Writer的流式CSV写入器
      Parameters:
      writer - the writer | 写入器
      Returns:
      the CSV writer | CSV写入器
    • writer

      public static CsvWriter writer(Writer writer, CsvConfig config)
      Creates a streaming CSV writer to a writer with configuration 使用配置创建到Writer的流式CSV写入器
      Parameters:
      writer - the writer | 写入器
      config - the CSV configuration | CSV配置
      Returns:
      the CSV writer | CSV写入器
    • writer

      public static CsvWriter writer(Path file)
      Creates a streaming CSV writer to a file using default configuration 使用默认配置创建到文件的流式CSV写入器
      Parameters:
      file - the file path | 文件路径
      Returns:
      the CSV writer | CSV写入器
      Throws:
      OpenCsvException - if the file cannot be opened | 如果无法打开文件
    • writer

      public static CsvWriter writer(Path file, CsvConfig config)
      Creates a streaming CSV writer to a file with configuration 使用配置创建到文件的流式CSV写入器
      Parameters:
      file - the file path | 文件路径
      config - the CSV configuration | CSV配置
      Returns:
      the CSV writer | CSV写入器
      Throws:
      OpenCsvException - if the file cannot be opened | 如果无法打开文件
    • isValid

      public static boolean isValid(String csv)
      Checks if a string is valid CSV 检查字符串是否为有效的CSV
      Parameters:
      csv - the CSV string | CSV字符串
      Returns:
      true if valid | 如果有效返回true
    • rowCount

      public static int rowCount(String csv)
      Counts the number of data rows in a CSV string (excluding header) 计算CSV字符串中的数据行数(不含标题行)
      Parameters:
      csv - the CSV string | CSV字符串
      Returns:
      the row count | 行数
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • headers

      public static List<String> headers(String csv)
      Extracts headers from a CSV string using default configuration 使用默认配置从CSV字符串提取标题
      Parameters:
      csv - the CSV string | CSV字符串
      Returns:
      the header list | 标题列表
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • headers

      public static List<String> headers(String csv, CsvConfig config)
      Extracts headers from a CSV string with the specified configuration 使用指定配置从CSV字符串提取标题
      Parameters:
      csv - the CSV string | CSV字符串
      config - the CSV configuration | CSV配置
      Returns:
      the header list | 标题列表
      Throws:
      OpenCsvException - if parsing fails | 如果解析失败
    • diff

      public static List<CsvChange> diff(CsvDocument original, CsvDocument modified)
      Computes differences between two CSV documents 计算两个CSV文档之间的差异
      Parameters:
      original - the original document | 原始文档
      modified - the modified document | 修改后的文档
      Returns:
      list of changes | 变更列表
    • diffByKey

      public static List<CsvChange> diffByKey(CsvDocument original, CsvDocument modified, String keyColumn)
      Computes differences using a key column for row matching 使用键列进行行匹配来计算差异
      Parameters:
      original - the original document | 原始文档
      modified - the modified document | 修改后的文档
      keyColumn - the key column header name | 键列标题名称
      Returns:
      list of changes | 变更列表
    • query

      public static CsvQuery query(CsvDocument doc)
      Creates a fluent query from a CSV document 从CSV文档创建流式查询
      Parameters:
      doc - the CSV document | CSV文档
      Returns:
      a new CsvQuery builder | 新的CsvQuery构建器
    • transform

      public static CsvTransform transform(CsvDocument doc)
      Creates a fluent transformation pipeline from a CSV document 从CSV文档创建流式转换管道
      Parameters:
      doc - the CSV document | CSV文档
      Returns:
      a new CsvTransform builder | 新的CsvTransform构建器
    • concat

      public static CsvDocument concat(CsvDocument... docs)
      Concatenates multiple CSV documents vertically (appends rows) 纵向连接多个CSV文档(追加行)
      Parameters:
      docs - the documents to concatenate | 要连接的文档
      Returns:
      the merged document | 合并后的文档
    • innerJoin

      public static CsvDocument innerJoin(CsvDocument left, CsvDocument right, String keyColumn)
      Joins two CSV documents using inner join on a key column 使用内连接在键列上连接两个CSV文档
      Parameters:
      left - the left document | 左文档
      right - the right document | 右文档
      keyColumn - the key column name | 键列名
      Returns:
      the joined document | 连接后的文档
    • leftJoin

      public static CsvDocument leftJoin(CsvDocument left, CsvDocument right, String keyColumn)
      Joins two CSV documents using left join on a key column 使用左连接在键列上连接两个CSV文档
      Parameters:
      left - the left document | 左文档
      right - the right document | 右文档
      keyColumn - the key column name | 键列名
      Returns:
      the joined document | 连接后的文档
    • stats

      public static CsvColumnStats stats(CsvDocument doc, String column)
      Computes summary statistics for a column 计算列的摘要统计信息
      Parameters:
      doc - the CSV document | CSV文档
      column - the column name | 列名
      Returns:
      the column statistics | 列统计信息
    • split

      public static List<CsvDocument> split(CsvDocument doc, int maxRows)
      Splits a CSV document into chunks of the specified size 将CSV文档按指定大小分割为块
      Parameters:
      doc - the CSV document | CSV文档
      maxRows - the maximum rows per chunk | 每块最大行数
      Returns:
      list of document chunks | 文档块列表
    • validator

      public static CsvValidator.Builder validator()
      Creates a new CSV validator builder 创建新的CSV校验器构建器
      Returns:
      a new validator builder | 新的校验器构建器
    • builder

      public static CsvDocument.Builder builder()
      Creates a new CSV document builder 创建新的CSV文档构建器
      Returns:
      a new document builder | 新的文档构建器
    • config

      public static CsvConfig.Builder config()
      Creates a new CSV configuration builder 创建新的CSV配置构建器
      Returns:
      a new config builder | 新的配置构建器