Skip to content

Conversation

@RamyHakam
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
Docs? no
Issues ----
License MIT

This PR adds a new CsvLoader class to the Store component for loading documents from CSV files. Each row in the CSV becomes a TextDocument, with configurable column mappings for content, ID, and metadata.

Features:

  • Configurable content column (by name or index)
  • Optional ID column mapping (generates UUID if not specified)
  • Metadata columns extraction
  • Custom delimiter, enclosure, and escape characters
  • Header row support (enabled by default)
  • Runtime options override via load() method
  • Automatic skipping of empty content rows
  • Proper handling of quoted content with commas and embedded quotes
Usage example:                                                                                                                  
$loader = new CsvLoader(                                                                                                        
    contentColumn: 'content',                                                                                                   
    idColumn: 'id',                                                                                                             
    metadataColumns: ['author', 'category']                                                                                     
);                                                                                                                              
                                                                                                                                
foreach ($loader->load('/path/to/data.csv') as $document) {                                                                     
    // $document is a TextDocument with content, ID, and metadata                                                               
}                    

@carsonbot carsonbot added Feature New feature Store Issues & PRs about the AI Store component Status: Needs Review labels Feb 1, 2026
- Add type annotation for $metadataColumns parameter
  Remove unnecessary false check after array_combine
  Use static arrow function in test
];

foreach ($metadataColumns as $column) {
$value = $this->getValue($data, $column);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it the same like:

Suggested change
$value = $this->getValue($data, $column);
$value = $data[$column] ?? null;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, this is simple
Fixed

@chr-hertel
Copy link
Member

Thanks for working on this - good one 👍

@RamyHakam RamyHakam requested a review from chr-hertel February 4, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature Status: Needs Review Store Issues & PRs about the AI Store component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants