如何使用 SQLite CLI 的“--skip 1"?选项? [英] How do I use the SQLite CLI's "--skip 1" option?
问题描述
我将多个 CSV 文件导入到一个表中.CSV 导入文档 说
I'm importing several CSV files into a single table. The documentation for CSV import says
当表格已经存在时,CSV 文件的每一行,包括第一行,都被假定为实际内容.如果 CSV 文件包含列标签的初始行,您可以使用--skip 1"选项使 .import 命令跳过该初始行.
when the table already exists, every row of the CSV file, including the first row, is assumed to be actual content. If the CSV file contains an initial row of column labels, you can cause the .import command to skip that initial row using the "--skip 1" option.
但我似乎无法找到传递该标志的有效方法.我尝试了以下方法:
But I can't seem to figure out a valid way to pass that flag. I tried the following:
sqlite> .import foo.csv contributions --skip 1
Usage: .import FILE TABLE
sqlite> .import --skip 1 foo.csv contributions
Usage: .import FILE TABLE
sqlite> .import foo.csv --skip 1 contributions
Usage: .import FILE TABLE
我使用的是 3.30.1 版.
I'm using version 3.30.1.
推荐答案
我发现在 3.32.0 上,这将跳过前两行,标题行和第一个数据行:
I find that on 3.32.0, this will work to skip the first two rows, the header row and the first data row:
.import --csv --skip 2 file.csv 表名
问题可能在于您所说的:
The issue may be where you say:
我使用的是 3.30.1
I'm using 3.30.1
根据 sqlite 发行说明,--skip
选项在 3.32.0 中实现:
According to the sqlite release notes, the --skip
option was implemented in 3.32.0:
SQLite 发布 3.32.0 于 2020-05-29 ...9. CLI 的增强:(a) 向 .import 命令添加选项:--csv、--ascii、--skip
SQLite Release 3.32.0 On 2020-05-29 ... 9. Enhancements to the CLI: (a) Add options to the .import command: --csv, --ascii, --skip
您可以从官方下载页面获取最新版本.
You can get the newest versions from the official download page.
这篇关于如何使用 SQLite CLI 的“--skip 1"?选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!