|
|
## How Can I Create a Data Package from Existing CSV Data?
|
|
|
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](About-the-Backup-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.
|
|
|
|
|
|
1. Create a new folder and rename it to add `.tabular` at the end of the folder name.
|
|
|
2. 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"
|
|
|
}
|
|
|
```
|
|
|
3. 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`, and `events` blank. Order matters. A spreadsheet editor may help you here.
|
|
|
4. If necessary, update the `dialect` object in to reflect the formatting of your CSV file. See [CSV Dialect](https://frictionlessdata.io/specs/csv-dialect/#specification) for more about this. |
|
|
\ No newline at end of file |