CSV Module
Using the CSV module you can import or export your data using CSV formatted files.
Configuration
Separator character
Character used to separate your data entries. Default value is ‘;’, a typical CSV entry woould look like username;password;phone;email
List separator character
Character used to separate entries in lists. This is used if one of the im- or exported fields contains a collection as value. Default value is ‘|’, a typical list entry would look like [1|2|3], where the braces indicate the value as list.
Charset
Charset of your data. Note: MS Excel in a western country will use Windows-1252
Date format
SimpleDateFormat used to import and export date values; e.g. "EEE, d MMM yyyy HH:mm:ss Z"
Usage
After setting the configuration parameters, you will be able to ex- or import data in the dashboard data screen. Additionally, you may use the REST interface to upload (import) or download (export) CSV data.
Export
To support the export of very large data entries, each field value of one data entry is limited to a size of 100.000 characters. This value can be increased in the yambas config file (limits.maxStringSizeOnExport).
The usual limitation of a maximum result set size is not taken into account when exporting data. Therefore, an export of a large dataset could last several minutes. You can limit the result set with the limit/order query operator (see example below).
curl https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
\
-u YOUR_EMAIL:YOUR_PASSWORD >
export
.zip
You may also filter classes to export using the ‘classesToExport’ query parameter and a comma separated list of classes which you want to be exported:
curl https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
?classesToExport=car,tire \
-u YOUR_EMAIL:YOUR_PASSWORD >
export
.zip
If you have multiple modules with classes that have the same name, you can prepend the classnames with the module name and a dollar sign after the module name:
curl https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
?classesToExport=MyModule$car,MyModule$tire \
-u YOUR_EMAIL:YOUR_PASSWORD >
export
.zip
You can also filter the data that you want to be exported by using a query:
curl https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
?q=lastModifiedAt>
date
(1413842400000) \
-u YOUR_EMAIL:YOUR_PASSWORD >
export
.zip
Or limit the resultset:
curl https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
?q=limit%20100&offset%2010 \
-u YOUR_EMAIL:YOUR_PASSWORD >
export
.zip
Usually, images are exported as URLs in the CSV. If you want them to be contained as files directly in the CSV, simply add the ‘exportResources’ parameter like follows:
curl https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
?exportResources=
true
\
-u YOUR_EMAIL:YOUR_PASSWORD >
export
.zip
Import
Assuming import.zip containing all classes as csv data, the import command would look like:
curl -X POST https:
//apiomat
.org
/yambas/rest/modules/csv/spec/YOUR_APPNAME
\
-u YOUR_EMAIL:YOUR_PASSWORD --data-binary @
import
.zip -H
"content-type:application/zip"
Each exported dataset of your own classes contains an ID field, which is the ID from ApiOmat database. Do NOT change this field if you want to update the dataset. If you create new entries, leave this field empty. Self-created IDs will lead to import errors. If you want to give your new data entries an ID, you can use an arbitrary (but unique) value in the foreignId field. You can even use this foreignId if you want to set references from other classes.
Special attribute types
If you want to import images, simply place them in the zip file and write their filename (beginning with file://) into the CSV. That is, if your csv includes myImport.zip* myImage.png* MyApp$MyClass1.csv
Than the column in your MyApp$MyClass1.csv file containing the images should contain file://myImage.png. Subdirectories are also supported.
If you want to use dates, their format must follow the Java date format LONG or SHORT.
My Modules
The CSV Module comes with a tool which allows you to import or export ZIP-files containing CSV Data in an easy dialog.
So you don’t have to use the Rest-Interface to download/upload your data.