Example no.3 - tens (or thousands) steps in one script. Many libraries used. | AFinScript © AFIN 2016 | |||||||
Start: [F5] or [Ctrl+Q] | ||||||||
<<< Parameters | Info: 5 columns (A:E = 'COCPI..T') from the #11 row are reserved for the AFinScript's program. | Start: [F5] or [Ctrl+Q] | ||||||
e.g. Path = | C:\AnyPath | |||||||
e.g. Database = | ||||||||
e.g. Period = | ||||||||
(…) | ||||||||
Class (Vendor) | Object | Command | Parameters | Info | The rest: Comments, calculations, row parameters | |||
AFinScriptStart | 0,004 | |||||||
# | This example is almost "professional". You have much of data in many separated files. You can consolidate them in one process UNDER YOUR FULL CONTROL. This is closed to professional data process making a data warehouse - your own data warehouse. This example is runable. | . | ||||||
. | . | |||||||
# | You can delete the database file and download it again everytime OR(!) drop the table in existing file only | . | ||||||
Afin.Shell | del C:\AnyPath\MyDatabase.accdb | 0,067 | ||||||
Afin.SQL | C:\AnyPath\MyDatabase.accdb | DROP TABLE MyDataTogether | . | |||||
# | Erase the data and wait a while to end Shell processes | . | ||||||
Afin.Shell | del C:\AnyPath\Faktury*.xls | 0,105 | ||||||
Afin.ScriptManager | Wait | TimeSeconds=2 | 2,006 | |||||
# | Download an EMPTY database from Internet | . | ||||||
Afin.Internet | http://afin.net/downloads/free/AfinSqlScript/TestAccessDB.accdb | DOWNLOAD | LocalFile=C:\AnyPath\MyDatabase.accdb | 1,244 | ||||
# | Download data (3 separate Excel files) | . | ||||||
Afin.Internet | http://afin.net/excel/soa/DaneDoCwiczenSOA/Faktury1.xls | DOWNLOAD | LocalFile=C:\AnyPath\Faktury1.xls | 0,074 | 1 | |||
# | The formula of the cell
above: ="http://afin.net/excel/soa/DaneDoCwiczenSOA/Faktury"&F23&".xls" |
The formula of the cell
above: ="LocalFile=C:\AnyPath\Faktury"&F23&".xls" |
. | |||||
Afin.Internet | http://afin.net/excel/soa/DaneDoCwiczenSOA/Faktury2.xls | DOWNLOAD | LocalFile=C:\AnyPath\Faktury2.xls | 0,069 | 2 | |||
Afin.Internet | http://afin.net/excel/soa/DaneDoCwiczenSOA/Faktury3.xls | DOWNLOAD | LocalFile=C:\AnyPath\Faktury3.xls | 0,073 | 3 | |||
# | In this way you can download (and than consolidate) hudreds of files - with ONE FORMULA and an index as line parameter. | |||||||
. | . | |||||||
# | Create an empty database table in an external database | . | ||||||
Afin.SQL | C:\AnyPath\MyDatabase.accdb | CREATE TABLE
MyDataTogether( SourceId VARCHAR(5), CustomerName VARCHAR(20), Sales DOUBLE) |
0,058 | |||||
# | Insert data from tables in defferent Excel files (index of file is in 'F' column) | . | ||||||
Afin.SQL | C:\AnyPath\MyDatabase.accdb | INSERT INTO MyDataTogether
SELECT '1' AS SourceId, Nazwa AS Name, wart_net AS Sales FROM [faktura$] IN 'C:\AnyPath\Faktury1.xls' [Excel 8.0;] |
0,078 | 1 | ||||
# | The formula of the cell
above: ="INSERT INTO MyDataTogether SELECT '"&F32&"' AS SourceId, Nazwa AS Name, wart_net AS Sales FROM [faktura$] IN 'C:\AnyPath\Faktury"&F32&".xls' [Excel 8.0;]" |
(The same parametrization rules) | . | |||||
Afin.SQL | C:\AnyPath\MyDatabase.accdb | INSERT INTO MyDataTogether
SELECT '2' AS SourceId, Nazwa AS Name, wart_net AS Sales FROM [faktura$] IN 'C:\AnyPath\Faktury2.xls' [Excel 8.0;] |
0,078 | 2 | ||||
Afin.SQL | C:\AnyPath\MyDatabase.accdb | INSERT INTO MyDataTogether
SELECT '3' AS SourceId, Nazwa AS Name, wart_net AS Sales FROM [faktura$] IN 'C:\AnyPath\Faktury3.xls' [Excel 8.0;] |
0,077 | 3 | ||||
# | Fill the sheet with data | . | ||||||
Afin.SQL | C:\AnyPath\MyDatabase.accdb | SELECT * FROM MyDataTogether |
PasteTo=ResultOfExampleNo3 | 0,071 | ||||
00:04,1 | ||||||||
Note: This process makes the data NOT IN THE MOST PROPER STATE. We intend to show a process, you can see this process in its full version in another example. |