UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

86 lines (85 loc) 3.05 kB
/** * CSV Processing Utility * Converts CSV files to LLM-friendly text formats * Uses streaming for memory efficiency with large files */ import type { FileProcessingResult, CSVProcessorOptions } from "../types/index.js"; /** * CSV processor for converting CSV data to LLM-optimized formats * * Supports three output formats: * - raw: Original CSV format with proper escaping (RECOMMENDED for best LLM performance) * - json: JSON array format (best for structured data processing) * - markdown: Markdown table format (best for small datasets <100 rows) * * All formats use csv-parser for reliable parsing, then convert to the target format. * * @example * ```typescript * const csvBuffer = Buffer.from('name,age\nAlice,30\nBob,25'); * const result = await CSVProcessor.process(csvBuffer, { * maxRows: 1000, * formatStyle: 'raw' * }); * console.log(result.content); // CSV string with proper escaping * ``` */ export declare class CSVProcessor { /** * Process CSV Buffer to LLM-friendly format * Content already loaded by FileDetector * * @param content - CSV file as Buffer * @param options - Processing options * @returns Formatted CSV data ready for LLM (JSON or Markdown) */ static process(content: Buffer, options?: CSVProcessorOptions): Promise<FileProcessingResult>; /** * Parse CSV string into array of row objects using streaming * Memory-efficient for large files */ /** * Parse CSV file from disk using streaming (memory efficient) * * @param filePath - Path to CSV file * @param maxRows - Maximum rows to parse (default: 1000) * @returns Array of row objects */ static parseCSVFile(filePath: string, maxRows?: number): Promise<unknown[]>; /** * Parse CSV string to array of row objects * Exposed for use by tools that need direct CSV parsing * * @param csvString - CSV data as string * @param maxRows - Maximum rows to parse (default: 1000) * @returns Array of row objects */ static parseCSVString(csvString: string, maxRows?: number): Promise<unknown[]>; /** * Format parsed CSV data for LLM consumption * Only used for JSON and Markdown formats (raw format handled separately) */ private static formatForLLM; /** * Format as markdown table * Best for small datasets (<100 rows) */ private static toMarkdownTable; /** * Format sample data according to the specified format * * @param sampleRows - Array of sample row objects * @param format - Output format for sample data * @param includeHeaders - Whether to include headers in CSV/markdown formats * @returns Formatted sample data as string or array */ private static formatSampleData; /** * Convert row objects to CSV string format * * @param rows - Array of row objects * @param includeHeaders - Whether to include header row * @returns CSV formatted string */ private static toCSVString; }