* csv2sql - conversion program to convert a csv file to sql format to allow easy checking / validation, and for import into a SQLite3 database using the SQLite '.read' command author: simon rowe license: open-source released under "New BSD License" created
(csvFileName string)
| 33 | */ |
| 34 | |
| 35 | func SQLFileName(csvFileName string) string { |
| 36 | // include the name of the csv file from command line (ie csvFileName) |
| 37 | // remove any path etc |
| 38 | var justFileName = filepath.Base(csvFileName) |
| 39 | // get the files extension too |
| 40 | var extension = filepath.Ext(csvFileName) |
| 41 | // remove the file extension from the filename |
| 42 | justFileName = justFileName[0 : len(justFileName)-len(extension)] |
| 43 | |
| 44 | sqlOutFile := "./.termdbms/SQL-" + justFileName + ".sql" |
| 45 | return sqlOutFile |
| 46 | } |
| 47 | |
| 48 | func Convert(csvFileName, tableName string, keepOrigCols bool) string { |
| 49 | // check we have a table name and csv file to work with - otherwise abort |