SQLite从Excel文件中导入数据
元数据另存为.csv格式
用记事本打开
打开后的数据
Android客户端开发的时候使用了SQLite数据库,为了测试,需要将一些excel文件中的数据导入到数据库的表中,下面是几个步骤:
数据库表的定义:
[*]createtablemydatas(idinteger,num1integer,num2integer,num3integer);
1、将Excel之中存储的数据另存为csv的格式bookroom.csv,注意不要带表头,只要数据就行。
导出之后的数据如下:
[*]30001,文理馆流通部,WenLiGuanLiuTongBu.png
[*]30002,经管院图书分馆,JingGuanYuanTuShuFenGuan.png
2、利用sqlite3的import命令将数据从文件导入到表中,在执行import之前需要用.separator命令设置数据的分隔符逗号,否者默认的分割符号是竖线'|'。
[*]sqlite3 test.db
[*]sqlite> .separator ','
[*]sqlite> .import bookroom.csv bookroom
import命令的格式:
[*].import <输入文件名> <插入表名>
3、这样数据就导入到了bookroom表中了,如下测试
[*]sqlite>select*frommydatas;
大功告成了!
页:
[1]