Skip to content

csv2sqlite is a fast and simple to use conversion tool that converts the content of a CSV file into a table in a SQLite database file.

License

Notifications You must be signed in to change notification settings

swepeba/csv2sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Banner csv2sqlite

License: MIT
csv2sqlite is a fast and simple to use conversion tool that converts the content of one or many CSV files into tables in a SQLite database file. Supports RFC 4180.

  • Comma character has to be used between columns.
  • Double quote characters (") can be used to mark the start and end of a column.
  • The number of columns is automatically found.
  • The tool will assume that the first row is a header row including the column names.

The tool can also be used to bulk import the content of many CSV files into the same SQLite database file.

Developed using C++.

Usage

usage: csv2sqlite.exe -o <db file> -f <csv file> [-t <name>] [-p <path>] [-h]

   -o <db file>      SQLite file (REQUIRED)
   -f <csv file>     CSV file    (REQUIRED)
   -t <name>         Use this table name                    (OPTIONAL)
   -p <path>         Path to CSV files, ignores -f and -t   (OPTIONAL)
   -h                Help

Examples

csv2sqlite.exe -o test.db -f statistics.csv
The data will be inserted into a table name named as the filename of the csv file. In this case to "statistics".

csv2sqlite.exe -o test.db -f statistics.csv -t numbers
The data will be inserted into a table name called "numbers".

csv2sqlite.exe -o test.db -p c:\temp
The data from all existing CSV files found in the path will be inserted into the same database file.

Please notice: If the table name already exists in the SQLite database and the number of columns matches, the content of the CSV file will be added to the table like an INSERT.

Execution time

Below, a CSV file with a file size of 61 570 904 bytes (~61.6 MB) was used.
Execution time was 297 ms on an i7-10510U running MS Windows 10 Pro (19045).

*** csv2sqlite ver. 1.1 (c) 2023, swepeba ***
MIT License - https://github.com/swepeba/csv2sqlite

INFORMATION
---> A new database file will be created

---> CSV file: test.csv
------> Rows in CSV file: 36420
------> Cols in CSV file: 26
------> Rows converted: 36420 (297 ms)
------> SUCCESS, all rows converted

Download

A pre-built and signed binary (.exe) is found in the latest release.

Release notes

ver. 1.1 (2023-05-17)

  • Support for -p <path> added.

ver. 1.0 (2023-05-16)

  • First release.

License

Copyright (c) swepeba. Licensed under the MIT License.

About

csv2sqlite is a fast and simple to use conversion tool that converts the content of a CSV file into a table in a SQLite database file.

Topics

Resources

License

Stars

Watchers

Forks