How Can I Create a Data Package from Existing CSV Data?
Is Quotemark's direct CSV import feature not enough for you? If you are comfortable working with JSON and CSV you can create your own package to import. Quotemarks supports a variation of the Tabular Data Package format which is essentially a folder with some CSV files containing your data and an index that glues it all together.
We recommend that you back up any existing data you have in the app first, and then start with a fresh app install.
- Create a new folder and rename it to add
.tabular
at the end of the folder name. - Inside this folder create a new file called
datapackage.json
using a plain text editor. This file describes where to find your CSV, the format of the data (called a "schema"), and how its encoded (the CSV "dialect"). Save the following text in this file:
{
"resources" : [
{
"name" : "Quotation",
"format" : "csv",
"path" : [
"quotation.csv"
],
"schema" : {
"fields" : [
{
"name" : "_id",
"format" : "uuid",
"type" : "string",
"constraints" : {
"required" : true,
"unique" : true
}
},
{
"type" : "string",
"name" : "quote"
},
{
"type" : "string",
"name" : "note"
},
{
"type" : "string",
"name" : "source"
},
{
"type" : "string",
"name" : "author"
},
{
"type" : "datetime",
"name" : "dateAdded"
},
{
"type" : "array",
"name" : "tags"
},
{
"type" : "array",
"name" : "events"
}
],
"primaryKey" : [
"_id"
],
"foreignKeys" : [],
"missingValues" : [
""
]
},
"mediatype" : "text\/csv",
"encoding" : "UTF-8",
"dialect" : {
"nullSequence" : "",
"delimiter" : ",",
"caseSensitiveHeader" : true,
"lineTerminator" : "\r\n",
"skipInitialSpace" : false,
"csvddfVersion" : "1.2",
"escapeChar" : "",
"quoteChar" : "\"",
"doubleQuote" : true,
"header" : true
},
"profile" : "tabular-data-resource"
}
],
"profile" : "tabular-data-package"
}
- Inside the same folder, save a CSV file called
quotation.csv
with your quotations including this header as the first line:"_id","quote","note","source","author","dateAdded","tags","events"
. In each row leave the fields_id
,tags
, andevents
blank. Order matters. A spreadsheet editor may help you here. - If necessary, update the
dialect
object in to reflect the formatting of your CSV file. See CSV Dialect for more about this.