Press "Enter" to skip to content

Script CSV

1 – Import CSV to TAGS using script
2 – Generic CSV script
3 – Export CSV script
4 – Export CSV script from current database

 

Examples:

 

1 – Import CSV to TAGS using script

Event OnAfterUpdate

if timer.csvupdate>3000 then
 'Example file name:
  filename = "c:\Program Files (x86)\LAquis\Apls\example1.csv"

 table.freeAll
 table.name="table1" 'Generic name
 table.colCount=100 'Max columns cache
 table.rowCount=1000 'Max rows cache
 table.import(filename, ",") 'Import
 last=table.find("",0)-1  'Find last row
 if last>0 then

  'Example tags:
   tag1=val(table.cell(2,last))
   tag2=val(table.cell(3,last))
   tag3=val(table.cell(4,last))

 end if
 timer.csvupdate.reset
end if

 

 

2 – Generic CSV script

table.freeAll
table.name="file1"
table.colCount=100
table.rowCount=1000
table.import("c:\Program Files (x86)\LAquis\Apls\example1.csv",",")

'Example:

table.show

msgbox(table.cell(2,0))
msgbox(table.cell(2,1))
msgbox(table.cell(2,2))
msgbox(table.cell(2,3))

 

table.show example:

 

You can use the values for anything using table.cell

Example:

x = val( table.cell(2,3) )

 

 

3 – Export CSV script

table.export("c:\Program Files (x86)\LAquis\Apls\exportexample1.csv",",")

 

 

 

4 – Export CSV script from current database

tags.exportCSVDatabase

or, export 3 days ago

tags.exportCSVDatabase(int(now)-3,int(now))

 

 

Question?