0

I am trying to import data from a csv to a sqlite3 database with an id integer primary key. After reading this SO question, I created a temporary table to import 11 columns from a csv file.

The Data:

a||b||c||d||e||f||g||h||i||j||k
l||m||n||o||p||q||r||s||t||u||v

I tried

.separator "||"
.import path/to/table tableName

I get the following error:

Error: path/to/table line 1: expected 11 columns of data but found 21

What am I doing wrong? Should the csv file be formatted differently?

NOTE: The list was built in AppleScript using a method similar to below. Could the echo in bash be causing a problem?

set delim to "||"
set myList to {"a", delim, "b", delim, "c", delim, "d", delim, "e", delim, "f", delim, "g", delim, "h", delim, "i", delim, "j", delim, "k", return, "l", delim, "m", delim, "n", delim, "o", delim, "p", delim, "q", delim, "r", delim, "s", delim, "t", delim, "u", delim, "v", return}
set myList to myList as text
set outPath to POSIX path of (path to desktop as text) & "data.csv"
do shell script "echo " & quoted form of myList & " > " & quoted form of outPath
Community
  • 1
  • 1
adayzdone
  • 11,120
  • 2
  • 20
  • 37

1 Answers1

1

return (0x0d) by itself does not seem to be a recognised line separator for .import (although it may vary by version since my .import will also only accept single character separators)

Try replacing return with linefeed in your generating AppleScript.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294