且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android中将数据从CSV文件复制到Sqlite文件

更新时间:2023-01-30 21:11:50

如果CSV文件中的列未映射到SQLite表中的列,则需要首先进行一些数据转换,即减少列数表中的列数,并相应地命名. 然后,您可以使用内置的CSV导入程序来导入数据.

If the columns in your CSV file don't map into the columns in your SQLite table then you need to do some data transformation first i.e. reduce the number of columns to the number of columns in your table, and name them accordingly. Then you can use the built-in CSV importer to import the data.

  1. 打开终端并启动sqlite提示.
  2. 将模式设置为csv

  1. Open a terminal and launch a sqlite prompt.
  2. Set mode to csv

sqlite> .mode csv

使用以下命令从csv文件导入数据:

Import the data from your csv file with the following command:

sqlite> .import c:/path/to/your/file/use/forward/slashes destination_table_name

这是一个非常好的教程. http://www.sqlitetutorial.net/sqlite-import-csv/

This is a really good tutorial. http://www.sqlitetutorial.net/sqlite-import-csv/