importing-to-seekdb
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImport Data Files to seekdb
将数据文件导入seekdb
Read, preview, and import CSV or Excel files into seekdb vector database with optional column vectorization for semantic search. Also provides collection delete functionality.
读取、预览并将CSV或Excel文件导入seekdb向量数据库,支持可选的列向量化以实现语义搜索。同时提供集合删除功能。
Path Convention
路径约定
Note: All paths in this document (e.g.,,scripts/) are relative to THIS skill directory, not the project root.example-data/
注意:本文档中的所有路径(如、scripts/)均相对于本skill目录,而非项目根目录。example-data/
Prerequisites
前置条件
- Python 3.10+ installed
- Required packages:
bash
pip install pyseekdb pandas openpyxl- 已安装Python 3.10+
- 所需依赖包:
bash
pip install pyseekdb pandas openpyxlSample Data
样本数据
Sample data files are provided in the directory:
example-data/| File | Description |
|---|---|
| Sample product data in CSV format |
| Sample product data in Excel format |
样本数据文件位于目录中:
example-data/| 文件 | 描述 |
|---|---|
| CSV格式的产品样本数据 |
| Excel格式的产品样本数据 |
Quick Start
快速开始
Use the provided script:
scripts/import_to_seekdb.pybash
undefined使用提供的脚本:
scripts/import_to_seekdb.pybash
undefinedImport with vectorization on Details column
对Details列进行向量化并导入
python scripts/import_to_seekdb.py import example-data/sample_products.csv --vectorize-column Details
python scripts/import_to_seekdb.py import example-data/sample_products.csv --vectorize-column Details
Import without vectorization
不进行向量化直接导入
python scripts/import_to_seekdb.py import example-data/sample_products.csv
python scripts/import_to_seekdb.py import example-data/sample_products.csv
Import Excel with custom collection name
导入Excel文件并指定自定义集合名称
python scripts/import_to_seekdb.py import example-data/sample_products.xlsx -v Description -c my_products
python scripts/import_to_seekdb.py import example-data/sample_products.xlsx -v Description -c my_products
Delete a collection
删除集合
python scripts/import_to_seekdb.py delete my_collection
> **Note**: To list all collections, use `query_from_seekdb.py list` from the `querying-from-seekdb` skill.python scripts/import_to_seekdb.py delete my_collection
> **注意**:如需列出所有集合,请使用`querying-from-seekdb` skill中的`query_from_seekdb.py list`命令。Scripts
脚本说明
This skill provides the following scripts in the directory:
scripts/| Script | Description |
|---|---|
| Main script with CLI interface for importing data and managing collections |
| Read and preview Excel files with detailed information |
本skill在目录下提供以下脚本:
scripts/| 脚本 | 描述 |
|---|---|
| 带CLI界面的主脚本,用于导入数据和管理集合 |
| 读取并预览Excel文件,显示详细信息 |
Available Commands
可用命令
import_to_seekdb.py
import_to_seekdb.py
| Command | Description |
|---|---|
| Import CSV/Excel file to seekdb with optional vectorization |
| Delete a collection from seekdb |
| 命令 | 描述 |
|---|---|
| 将CSV/Excel文件导入seekdb,支持可选向量化 |
| 从seekdb中删除集合 |
read_excel.py
read_excel.py
Read and preview Excel files before importing:
bash
undefined导入前读取并预览Excel文件:
bash
undefinedBasic preview (show file info and first 5 rows)
基础预览(显示文件信息和前5行)
python scripts/read_excel.py example-data/sample_products.xlsx
python scripts/read_excel.py example-data/sample_products.xlsx
List all sheets
列出所有工作表
python scripts/read_excel.py example-data/sample_products.xlsx --list-sheets
python scripts/read_excel.py example-data/sample_products.xlsx --list-sheets
Preview specific sheet with more rows
预览指定工作表并显示更多行数
python scripts/read_excel.py data.xlsx --sheet "Sheet2" --rows 20
python scripts/read_excel.py data.xlsx --sheet "Sheet2" --rows 20
Show column information and statistics
显示列信息和统计数据
python scripts/read_excel.py example-data/sample_products.xlsx --columns --stats
python scripts/read_excel.py example-data/sample_products.xlsx --columns --stats
Export to CSV
导出为CSV
python scripts/read_excel.py example-data/sample_products.xlsx --to-csv output.csv
| Option | Description |
|--------|-------------|
| `--sheet, -s` | Sheet name to read (default: first sheet) |
| `--rows, -r` | Number of rows to preview (default: 5) |
| `--list-sheets, -l` | List all sheets and exit |
| `--columns, -c` | Show detailed column information |
| `--stats` | Show statistics for numeric columns |
| `--to-csv` | Export sheet to CSV file |
| `--all-rows, -a` | Display all rows |python scripts/read_excel.py example-data/sample_products.xlsx --to-csv output.csv
| 选项 | 描述 |
|--------|-------------|
| `--sheet, -s` | 要读取的工作表名称(默认:第一个工作表) |
| `--rows, -r` | 要预览的行数(默认:5) |
| `--list-sheets, -l` | 列出所有工作表后退出 |
| `--columns, -c` | 显示详细的列信息 |
| `--stats` | 显示数值列的统计数据 |
| `--to-csv` | 将工作表导出为CSV文件 |
| `--all-rows, -a` | 显示所有行 |Workflow
工作流程
The script automatically handles the following steps:
import_to_seekdb.py- Read Data File - Supports CSV (.csv) and Excel (.xlsx, .xls) formats
- Connect to seekdb - Uses environment variables for server mode, or embedded mode by default
- Create Collection - With optional vectorization using default embedding function (all-MiniLM-L6-v2, 384 dimensions)
- Import Data - Batch processing with configurable batch size
- Verify - Displays record count and data preview after import
import_to_seekdb.py- 读取数据文件 - 支持CSV(.csv)和Excel(.xlsx, .xls)格式
- 连接seekdb - 默认使用嵌入式模式,服务器模式需使用环境变量配置
- 创建集合 - 可选使用默认嵌入函数(all-MiniLM-L6-v2,384维度)进行向量化
- 导入数据 - 支持可配置批量大小的批量处理
- 验证 - 导入完成后显示记录数和数据预览
User Interaction Guide
用户交互指南
For Reading Excel Files
读取Excel文件
When user wants to preview or inspect an Excel file before importing:
bash
undefined当用户希望在导入前预览或检查Excel文件时:
bash
undefinedPreview file structure and data
预览文件结构和数据
python scripts/read_excel.py <file_path>
python scripts/read_excel.py <file_path>
With column details and statistics
显示列详情和统计数据
python scripts/read_excel.py <file_path> --columns --stats
This helps users:
- Understand the file structure (sheets, columns, row count)
- Identify which column to vectorize
- Check data quality before importingpython scripts/read_excel.py <file_path> --columns --stats
这有助于用户:
- 了解文件结构(工作表、列、行数)
- 确定需要向量化的列
- 导入前检查数据质量For Data Import
数据导入
When user requests data import, ask:
- File path: "Please provide the path to your CSV or Excel file."
- If user needs sample data, use files from the directory
example-data/ - Suggest using to preview the file first
read_excel.py
- If user needs sample data, use files from the
- Vectorization: "Would you like to enable vector search by vectorizing a column? (yes/no)"
- Column selection (if yes): "Which column to vectorize? (e.g., 'Details', 'Description')"
- Collection name: "Collection name? (default: derived from filename)"
- Connection mode: "Embedded (local) or server mode?"
当用户请求数据导入时,需询问以下信息:
- 文件路径:"请提供您的CSV或Excel文件路径。"
- 若用户需要样本数据,使用目录下的文件
example-data/ - 建议先使用预览文件
read_excel.py
- 若用户需要样本数据,使用
- 向量化:"是否需要通过向量化某一列来启用向量搜索?(是/否)"
- 列选择(如果选择是):"要向量化哪一列?(例如:'Details'、'Description')"
- 集合名称:"集合名称?(默认:从文件名派生)"
- 连接模式:"嵌入式(本地)还是服务器模式?"
For Collection Management
集合管理
- List collections: Use from the
query_from_seekdb.py listskillquerying-from-seekdb - Delete collection: Run
python scripts/import_to_seekdb.py delete <collection_name>
- 列出集合:使用skill中的
querying-from-seekdb命令query_from_seekdb.py list - 删除集合:运行
python scripts/import_to_seekdb.py delete <collection_name>
Embedding Functions
嵌入函数
The script uses the default embedding function (all-MiniLM-L6-v2, 384 dimensions) when vectorization is enabled via .
--vectorize-column当通过启用向量化时,脚本会使用默认嵌入函数(all-MiniLM-L6-v2,384维度)。
--vectorize-columnHandling Large Files
大文件处理
For files with >10,000 rows, the script uses batch processing automatically. You can configure batch size:
import_to_seekdb.pybash
python scripts/import_to_seekdb.py import large_file.csv -v Details --batch-size 500对于行数超过10,000的文件,脚本会自动使用批量处理。您可以配置批量大小:
import_to_seekdb.pybash
python scripts/import_to_seekdb.py import large_file.csv -v Details --batch-size 500