在Android中将数据从CSV文件复制到Sqlite文件 [英] Copy Data from CSV file to Sqlite file in Android

查看:234
本文介绍了在Android中将数据从CSV文件复制到Sqlite文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据从CSV文件复制到我的android应用程序的SQLite文件中.SQLite表结构,即列与CSV文件列不同. CSV文件中还有更多列.我正在尝试使用DB Browser SQLite软件.

I want to copy the data from CSV file to SQLite file for my android application.SQLite table structure i.e. the columns are different than the CSV file columns. There are more columns in the CSV file. I am trying to use DB Browser For SQLite software.

是否可以通过这些应用程序复制数据,或者我应该编写一些代码来做到这一点?有人可以建议吗?

Is it possible to copy data through these this Application or should I be writing some code to do that? Can anyone please suggest?

推荐答案

如果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/

这篇关于在Android中将数据从CSV文件复制到Sqlite文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆