AskiaAnalyse via the Command Line
Table of contents:
Since version 5.1.3.4, AskiaAnalyse can be used via the command line which is extremely useful with AskiaVista's automated & scheduled tasks.
You can invert data stored in SQL Server.
This feature is crucial when AskiaField surveys are initialized in SQL Server in the CCA.
This feature is used by AskiaVista to have retrieve live survey data in order to display up to date analysis results.
Note: We will add further functionality as requests are made.
This feature has been updated from version 5.3.1 to use a temporary directory during the inversion process, minimizing system downtime while running the inversion.
Definition
Here the list of arguments which can appear in the command line to start AskiaAnalyse:
Argument | Value | Description |
{None} | String | Path of survey file, QES, specified between quotes " |
/invert | - | Use to invert the data |
/partialinvert | - | Attempt to invert the database incrementally (only adding new interviews) |
/verifyinvert | - | Verifies the number of interviews between inverted DB and DB are the same and inverts if needed (as of v5.3.5 this argument appears to also execute the "recalculate variable" function) |
/type: |
Integer | Defines the type of survey and/or data, for example: /type:5
|
/type:0 Data stored in a QES file |
||
/type:1 Dimension file (PKD, SAV, etc...) |
||
/type:2 Multiple askia surveys QEM |
||
/type:3 AskiaSurf QEW file |
||
/type:4 Data stored in SQL Server Legacy format (multiple tables) |
||
/type:5 Data stored in SQL Server new format (single table) |
||
/type:7 When referring to a .QEX file which uses data stored in SQL Server new format (single table) - if you use a .QEX file and .DAT folder locally, you can omit the type parameter |
||
/surveyId: | Integer | Defines the ID of a survey when the data is stored in the SQL Server, /type:4, for example: /surveyId:119 |
/surveyConnection: | String | Defines the connection string to the survey data stored in SQL Server and/or Dimensions, for example:/surveyConnection:"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=UID;password=PWD;Initial Catalog=Surveys;Data Source=127.0.0.1"
|
/recalculatevariables | - | Recalculate all variables |
/exportword | - | Export portfolio to word - requires /portfolio and /output, optional script |
/exportexcel | - | Export portfolio to excel - requires /portfolio and /output, optional script |
/exportppt | - | Export portfolio to ppt - requires /portfolio and /output, optional script |
/exporttabsml | - | Export portfolio to TabsML - requires /portfolio and /output, optional script |
/exportjson | - | Export aggregated table data to .json format i.e. the json contains the cell values and text of the table (not conversion of xml to json portfolio) |
/exportascii | - | Export portfolio to Ascii - requires /portfolio and /output, optional script |
/exportsptoinv | - |
Export a sub population to an inverted QES - requires /script, /output, optional /calculated, /exclude |
/"questions:" | String |
A selection of questions can be chosen when exporting to inverted database. e.g. /"questions:gender;age;rating" |
/portfolio: | String | Path of the portfolio. From Analyse 64 bit 5.3.5.5 11/10/2016 onwards, can also use /portfolio2, /portfolio3, /portfolio4 etc. - see third example below. |
/output: | String | Path of the file to export. From Analyse 64 bit 5.3.5.5 11/10/2016 onwards, can also use /output2, /output3, /output4 etc. - see third example below. |
/script: | String | Script to define a sub-population |
/calculated: | String | List of calculated questions needed eg /"calculated:weighting1;weighting2;timingondemographics" |
/exclude: | String | List of excluded questions eg /"exclude:wave;bankaccount" |
/hkcu | - |
This uses the current user settings and not the local machine's settings which are default (HKCM). Use this parameter if tab or general settings don't match your manual output. |
/replacetabtemplate: | String |
/replacetabtemplate:"OldTabTemplate|NewTabTemplate" - use this for replacing tab-templates before running an export from the command line. You can call this parameter more than once to change more than one tab-template. If the tab-template is not recognised, an error will be written in the log file (if you have specified one). |
/logfile: | String |
/"logfile:Log.txt" - Creates a date time stamped list of all command syntax run which referred to the specified log file. New runs are appended to the bottom for the log file. |
/startsheet: | Integer |
/startsheet:5 (default 1) - specify the number of the starting sheet when exporting to excel from the command line. This does not override the option 'Use portfolio titles for sheet names' - you either have to have a tab definition with no title or have the option set to 'No' |
/automate: | String |
/"automate:CreateSummaryTabs.txt" specify the generic script file to create portfolios such as summary tabs or hole-counts from the command line. You can specify where to save the newly created portfolio in the automation script and then open this and export to Excel in a following command. |
/completesonly: | Number |
Number values take 0 & 1. Place the parameter after your data file in the command line. /completesonly:1 will set Analyse to show only completes. /completesonly:0 will set Analyse to show completes and incompletes. |
/fastmetadata |
- |
Instructs Analyse to generate the fast meta data files for your .QEW or .QES file |
From 5.6.1.0 |
|
|
/url:"" | String |
CcaWebAPI URL to use when opening a live survey. /url:"https://MyServer/CcaWebAPI" |
/username:"" | String |
Supervisor's user name used to connect the CcaWebAPI when opening a live survey (used by /url) /username:"Supervisor" |
/password:"" | String |
Supervisor's password used to connect the CcaWebAPI when opening a live survey (used by /url and /username) /password:"Supervisor pwd" |
/parameters: | String |
e.g. /parameters:"C:\Users\Admin\MyFilePath\,42" Used by Analyse to gather parameters from the command line and use them in automation scripts. Parameters are comma separated. Example automation script set-up shown below: Dim arrParm as StringArray = GetCommandParameters() |
Examples
1. Recalculate and invert data of a QES file when data are stored in SQL server.
Analyse.exe "C:\MyQes\Ex.qes" /surveyconnection:"Provider=sqloledb; Data Source=XXXXXXX; Initial Catalog=Surveys;Trusted_Connection=no;User Id=XXXXXX;Password=XXXXX";" /surveyid:249 /type:5 /recalculatevariables /invert
2. Export to inverted format of a Surf file with calculated questions.
AnalyseU.exe "C:\My QEWs\Ex.qew" type:3 /exportsptoinv /"script:??Lang?? Has 1" /"calculated:Weighting" /"exclude:Wave" /"output:C:\My Qes\reduced.qes"
3. Export of a portfolio to Excel on a sub-population.
AnalyseU.exe "C:\My QES\Ex.qes" /exportexcel /"script:??Lang?? Has 1" /"portfolio:C:\My QES\MyAnalysis.xml" /"output:C:\My Qes\result.xls"
4. Export multiple portfolios to multiple Excel files in a single command / session of Analyse:
(Only available from Analyse 64 bit 5.3.5.5 11/10/2016 onwards).
Analyse.exe "c:\qes\me\ex.qes" /exportexcel /portfolio:"c:\qes\me\p1.xml" /output:"c:\qes\me\p1.xlsx" /portfolio2:"c:\qes\me\portfolio.xml" /output2:"c:\qes\me\poorttfolio.xlsx"
5. Replace tab template before exporting:
Analyse.exe "C:\Qes\ex.qes" /exportexcel /"portfolio:C:\Qes\JustCount.xml" /"output:C:\Qes\result.xls" /replacetabtemplate:"FlatCount|FlatCountAndPercentage" /"logfile:C:\Qes\Log.txt"
6. Set start sheet in Excel to be 5:
Analyse.exe "C:\Qes\ex.qes" /exportexcel /"portfolio:C:\Qes\JustCount.xml" /"output:C:\Qes\result.xls" /"logfile:C:\Qes\Log.txt" /startsheet:5
7. Generate Fast metadata from the command line:
Analyse.exe "C:\My qes\LatestVersion.qew" /fastmetadata
8. Run an automation script from the command line:
Analyse.exe "C:\Qes\ex.qes" /"automate:C:\Qes\CreateSummaryTabs.txt"
Analyse.exe "C:\Qes\ex.qes" /exportexcel /"portfolio:C:\Qes\CreatedSummaryTabs.xml" /"output:C:\Qes\SummaryTabs.xls"
From 5.6.1.0
9. Open live data from the command line:
"Analyse.exe" /url:"http://10.0.51.21/CcaWebAPI" /username:"!Askia_Seyf" /password:"*****" /surveyId:9999 /exportexcel /"portfolio:OpenLiveDataPortfolio.xml" /"output:myLiveData.xlsx"
10. Parameters given in the command line to be used by the automation script that it is running:
"Analyse.exe" "EX_NEW.qes" /"automate:V-1083-AutoScript.txt" /parameters:"C:\MyFilePath\,42"
Note:
1. Survey projects using QEM are no longer supported, as this file format has been deprecated since version 5.1.x in AskiaAnalyse, and version 5.3.0.0 in AskiaVista. The QEM format was made obsolete with the release of AskiaSurf and its much more modern, flexible & powerful QEW format.
Return error codes
Add this on a new line after your command has run to capture the error code in the command window:
cmd /k echo Exit Code is %errorlevel%
The process can return the values below. For more information, you may find this article useful.
#define AER_NO_ERROR 0
#define AER_LOGIN_REFUSED -1
#define AER_SURVEY_NOT_FOUND -2
#define AER_CANNOT_OPEN_SURVEY_FILE -3
#define AER_CANNOT_READ_FILE -4
#define AER_SURVEY_TYPE_NOT_SUPPORTED -5
#define AER_INVALID_PORTFOLIO_FILE -6
#define AER_CANNOT_CREATE_OUTPUT -7