How to Automate Exports
Automating exports by using AskiaTools via batch scripts can be a very useful process and save you a lot of time. Here are a few steps that will explain how this can be done . . .
Firstly create a batch (text ansi) file with the extension .bat (eg ''myjob.bat").
1. Reference the AskiaTools executable
Insert an initial command line with:
Tools.exe (or) "C:\Program Files (x86)\Askia\tools.exe"
2. Add the metadata source path
"C:\my directory\My Qes File.qes"
3. Add the connection mode
- Using ccawebapi / live surveys (from 5.4.9)
/url:"https://MyServer/CcaWebAPI"
/username:"Supervisor" (Supervisor askiafield username)
/password:"Supervisor pwd" (Supervisor askiafield password)
/surveyid:xxx (xxx => Askiafield ID survey)
- Use a SQL query string
/surveyconnection:"Provider=SQLOLEDB.1;Data Source=127.0.0.1;Initial Catalog=Surveys;Persist Security Info=False;UID=XXX;PWD=xxx"
/surveyid:xxx
4. Add the case data source path
/type:0 (qes)
/type:1 (SQL legacy format)
/type:2 (inverted data format)
/type:3 (SQL new format)
/type:4 (data stored in webinterviews SQL database)
/type:5 (ccawebapi)
Add the webinterviews SQL table used when exporting data from Webinterviews, if
/type:4 /webtable:"Surveyname in askiafield"
5. Add the export format
At least one of the following options is required
/completes (To export all completed interviews)
/incompletes (To export incompleted intrerviews also)
- To fixed length ASCII data
/Exportfixedlength /completes /incompletes /datafile:"c:\my directory\File.asc"
NB: this format requires to set first a data map definition:
- To delimited ASCII data
We recommend that you specify the /closedtype export and /reapeatmultipleseparator , if you want to export the same number of multiple response separators . . .
/closetype:1 (order)
/closetype:2 (caption)
/closetype:3 (entry codes)
/closetype:4 (entry codes as numeric) and/ Reape
/exportdelimited /sepquestion:; /sepresponse:, /closedtype:3 /repeatmultipleseparator /completes /incompletes /datafile:"c:\my directory\File.txt"
- To SPSS .SAV
/exportsav /completes /incompletes /datafile:"c:\my directory\File.sav"
- To Triple-S
/exporttriples /generate /completes /incompletes /datafile:"c:\my directory\File.sss"
- To multimedia files
/exportmultimedia /completes /incompletes /datafile:"??shortcut????id??" /directory:"c:\my directory" /questions:"q1;q2"
. . . where "q1;q2" are the open-ended questions, where the multimedia files are stored/
6. Add selected questions
Select questions using their shortcut
/questions:"^i2_Age^;^i1_gender^"
Select questions based on their properties
- Using /questionselection (from v 5.6.0)
/questionselection:"(CurrentQuestion.Type has {\"open\";\"datetime\"} )"
- Using tags "Demog" + "LifeStyle" and open-ended with anonymised question
/questionselection:"(CurrentQuestion.Tags Has {\"Demog\";\"LifeStyle\"} or CurrentQuestion.Type = \"open\") And (CurrentQuestion.IsAnonymised = False)"
- Add a filter
/additionalfilter:"i1_Gender = 1"
- Add a new data column on-the-fly (from 5.4.9.4)
You can add as many columns as you wish using the following syntax.
/addcolumn:"Male:^i1_Gender^ has {1}" /addcolumn:"Female:^i1_Gender^ has {2}"
7. Examples
- Export fixed length ASCII data from a QES file
Tools.exe "C:\my directory\My Qes File.qes" /Exportfixedlength /completes /incompletes /datafile:"c:\my directory\File.asc"
- Export delimited ASCII data from a QES file
Tools.exe "C:\my directory\My Qes File.qes" /exportdelimited /completes /sepquestion:; /sepresponse:, /datafile:"c:\my directory\File.asc"
- Export delimited ASCII data stored in SQL
Tools.exe "C:\my directory\My Qes File.qes" /exportdelimited /completes /sepquestion:; /sepresponse:, /type:1 /surveyconnection:"Provider=SQLOLEDB.1;Data Source=127.0.0.1;Initial Catalog=Surveys;Persist Security Info=False;UID=XXX;PWD=xxx" /surveyid:xxx /datafile:"c:\folder\data.txt" /logfile:"c:\folder\log.txt"
- Export delimited ASCII data stored in inverted files
Tools.exe "C:\my directory\My Qes File.qes" /type:2 /exportdelimited /completes /sepquestion:; /sepresponse:, /datafile:"c:\my directory\File.asc"
- Export .SAV from a QES
Tools.exe "C:\my directory\My Qes File.qes" /exportsav /completes /datafile:"c:\my directory\File.sav"
- Export Triple-S from a QES
Tools.exe "C:\my directory\My Qes File.qes" /exporttriples /generate /completes /datafile:"c:\my directory\File.sss"
- Export multimedia files
Tools.exe "C:\my directory\My Qes File.qes" /exportmultimedia /completes /datafile:"??shortcut????id??" /directory:"c:\my directory" /questions:"q1;q2"
- Export .SAV excluding questions (from version 5.4.8)
Tools.exe "C:\my directory\My Qes File.qes" /exportsav /datafile:"C:\my directory\Output.sav /excludequestions:"Q1;Q2;Q3"
- Export delimited ASCII from a live survey (from version 5.4.9)
Tools.exe /url:"http://ServerName/CcaWebApi" /username:"Supervisor" /password:"pwd" /surveyId:11 /exportdelimited /datafile:"c:\Qes\IhisOut.txt" /completes
To discover more options for the AskiaTools command line, see here.