importing-to-seekdb

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Import 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/
,
example-data/
) are relative to THIS skill directory, not the project root.
注意:本文档中的所有路径(如
scripts/
example-data/
)均相对于本skill目录,而非项目根目录。

Prerequisites

前置条件

  • Python 3.10+ installed
  • Required packages:
bash
pip install pyseekdb pandas openpyxl
  • 已安装Python 3.10+
  • 所需依赖包:
bash
pip install pyseekdb pandas openpyxl

Sample Data

样本数据

Sample data files are provided in the
example-data/
directory:
FileDescription
sample_products.csv
Sample product data in CSV format
sample_products.xlsx
Sample product data in Excel format
样本数据文件位于
example-data/
目录中:
文件描述
sample_products.csv
CSV格式的产品样本数据
sample_products.xlsx
Excel格式的产品样本数据

Quick Start

快速开始

Use the provided
scripts/import_to_seekdb.py
script:
bash
undefined
使用提供的
scripts/import_to_seekdb.py
脚本:
bash
undefined

Import 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
scripts/
directory:
ScriptDescription
import_to_seekdb.py
Main script with CLI interface for importing data and managing collections
read_excel.py
Read and preview Excel files with detailed information
本skill在
scripts/
目录下提供以下脚本:
脚本描述
import_to_seekdb.py
带CLI界面的主脚本,用于导入数据和管理集合
read_excel.py
读取并预览Excel文件,显示详细信息

Available Commands

可用命令

import_to_seekdb.py

import_to_seekdb.py

CommandDescription
import <file>
Import CSV/Excel file to seekdb with optional vectorization
delete <name>
Delete a collection from seekdb
命令描述
import <file>
将CSV/Excel文件导入seekdb,支持可选向量化
delete <name>
从seekdb中删除集合

read_excel.py

read_excel.py

Read and preview Excel files before importing:
bash
undefined
导入前读取并预览Excel文件:
bash
undefined

Basic 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
import_to_seekdb.py
script automatically handles the following steps:
  1. Read Data File - Supports CSV (.csv) and Excel (.xlsx, .xls) formats
  2. Connect to seekdb - Uses environment variables for server mode, or embedded mode by default
  3. Create Collection - With optional vectorization using default embedding function (all-MiniLM-L6-v2, 384 dimensions)
  4. Import Data - Batch processing with configurable batch size
  5. Verify - Displays record count and data preview after import
import_to_seekdb.py
脚本会自动处理以下步骤:
  1. 读取数据文件 - 支持CSV(.csv)和Excel(.xlsx, .xls)格式
  2. 连接seekdb - 默认使用嵌入式模式,服务器模式需使用环境变量配置
  3. 创建集合 - 可选使用默认嵌入函数(all-MiniLM-L6-v2,384维度)进行向量化
  4. 导入数据 - 支持可配置批量大小的批量处理
  5. 验证 - 导入完成后显示记录数和数据预览

User Interaction Guide

用户交互指南

For Reading Excel Files

读取Excel文件

When user wants to preview or inspect an Excel file before importing:
bash
undefined
当用户希望在导入前预览或检查Excel文件时:
bash
undefined

Preview 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 importing
python scripts/read_excel.py <file_path> --columns --stats

这有助于用户:
- 了解文件结构(工作表、列、行数)
- 确定需要向量化的列
- 导入前检查数据质量

For Data Import

数据导入

When user requests data import, ask:
  1. File path: "Please provide the path to your CSV or Excel file."
    • If user needs sample data, use files from the
      example-data/
      directory
    • Suggest using
      read_excel.py
      to preview the file first
  2. Vectorization: "Would you like to enable vector search by vectorizing a column? (yes/no)"
  3. Column selection (if yes): "Which column to vectorize? (e.g., 'Details', 'Description')"
  4. Collection name: "Collection name? (default: derived from filename)"
  5. Connection mode: "Embedded (local) or server mode?"
当用户请求数据导入时,需询问以下信息:
  1. 文件路径:"请提供您的CSV或Excel文件路径。"
    • 若用户需要样本数据,使用
      example-data/
      目录下的文件
    • 建议先使用
      read_excel.py
      预览文件
  2. 向量化:"是否需要通过向量化某一列来启用向量搜索?(是/否)"
  3. 列选择(如果选择是):"要向量化哪一列?(例如:'Details'、'Description')"
  4. 集合名称:"集合名称?(默认:从文件名派生)"
  5. 连接模式:"嵌入式(本地)还是服务器模式?"

For Collection Management

集合管理

  • List collections: Use
    query_from_seekdb.py list
    from the
    querying-from-seekdb
    skill
  • Delete collection: Run
    python scripts/import_to_seekdb.py delete <collection_name>
  • 列出集合:使用
    querying-from-seekdb
    skill中的
    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
.
当通过
--vectorize-column
启用向量化时,脚本会使用默认嵌入函数(all-MiniLM-L6-v2,384维度)。

Handling Large Files

大文件处理

For files with >10,000 rows, the
import_to_seekdb.py
script uses batch processing automatically. You can configure batch size:
bash
python scripts/import_to_seekdb.py import large_file.csv -v Details --batch-size 500
对于行数超过10,000的文件,
import_to_seekdb.py
脚本会自动使用批量处理。您可以配置批量大小:
bash
python scripts/import_to_seekdb.py import large_file.csv -v Details --batch-size 500

References

参考资料