PureBytes Links
Trading Reference Links
|
<FONT face=Arial
color=#0000ff size=2>it already has a csv appended to it since I'm getting
the file name from the files object of the folder.
<FONT face=Arial
color=#0000ff size=2>
<FONT face=Arial
color=#0000ff size=2>I agree on the single file but I didn't write the original
AFL formula. I was going to sugges that to herman. This code will work on a
single file or multiple files - just requires a change in the format
file.
<FONT face=Arial
color=#0000ff size=2>
<FONT face=Arial
color=#0000ff size=2>Here's the latest version if you'd care to take a
look. Thanks for the help.
<FONT face=Arial color=#0000ff
size=2>d
<FONT
color=#0000ff>-<SPAN
class=304335119-13042004>------------------------------------------------------------------------------------------------------------
<SPAN
class=304335119-13042004>'**************************************'Purpose:
Run A Procedure in
Amibroker' that will export
quotes from' one database
into CSV files ' and then
import them into ' another
database.''Created By:
dingo'**************************************
<SPAN
class=304335119-13042004>Dim oABDim oAADim fsoDim fldrDim
flsDim fleDim flenamDim result
<SPAN
class=304335119-13042004>dim RT_DB_Pathdim EOD_DB_Pathdim
Frmla_Pathdim CSV_Dirdim CSV_FleNamdim
FmtFleNam
<SPAN
class=304335119-13042004>'-------------------------------------------------------'
change the following paths to suit your
configuration'-------------------------------------------------------RT_DB_Path
= "C:\Program Files\Amibroker\Data"EOD_DB_Path = "C:\Program
Files\Amibroker\TC2000"Frmla_Path = "C:\Program Files\Amibroker\AFL\EOD
Export.Afl"CSV_Dir = "C:\Program Files\Amibroker\Output"FmtFleNam =
"C:\Program
Files\Amibroker\Formats\EOD_To_RT.Format"
<SPAN
class=304335119-13042004>' declare object for Amibroker and the file system
objectset oAB = CreateObject("Broker.Application")Set oAA =
oAB.Analysisset fso =
CreateObject("Scripting.FileSystemObject")
<SPAN
class=304335119-13042004>'------------------------------------------' Delete
all csv files in the CSV folder' so that we don't import any old ones'
that may still be
there'------------------------------------------wscript.echo "Cleaning
Out " + CSV_Dir' set the folder objectSet fldr =
fso.GetFolder(CSV_Dir)' set the files objectSet fls =
fldr.FilesFor Each fle in fls flenam =
fle.name ' make sure its a csv file
if right(ucase(flenam), 4) = ".CSV"
then ' Import the CSV File using
the correct format
fle.Delete end ifNext' destroy the folder and file
objectsset fle = nothingset fls =
nothing
<SPAN
class=304335119-13042004>'------------------------------------------' Set
from and to dates, and the
watchlist'------------------------------------------with
oAA .RangeMode = 3 .RangeFromDate =
"01/01/2001" .RangeToDate =
"12/31/2002" .ClearFilters .ApplyTo
= 2 .Filter(0, "watchlist") = 29end
with
<SPAN
class=304335119-13042004>'------------------------------------------' The
following is the "main" code for the' exporting and importing of the
data'------------------------------------------' Load EOD Data
Basewscript.echo "Loading EOD Database: " + EOD_DB_PathIf
oAB.LoadDatabase(EOD_DB_Path) Then ' Load the AFL for
Building the CSV File wscript.echo "Loading AFL: " +
Frmla_Path if oAA.LoadFormula(Frmla_Path)
Then ' Run The
Scan wscript.echo "Running
Scan" result = oAA.Scan
' now load the RT
Database wscript.echo "Loading RT
Database: " + RT_DB_Path If
oAB.LoadDatabase(RT_DB_Path)
Then '
import each csv file in the EODexports folder
' set the
files
object Set
fls =
fldr.Files
For Each fle in
fls
flenam =
fle.name
' make sure its a csv
file
if right(ucase(flenam), 4) = ".CSV"
then
' Import the CSV File using the correct
format
CSV_FleNam = CSV_Dir + "\" +
flenam
wscript.echo "Importing " +
CSV_FleNam
result = oAB.Import(0, CSV_FleNam, FmtFleNam)
if result <> 0
Then
msgbox "Error Running
Import"
Exit
For
end
if
end if
Next
oAB.RefreshAll()
wscript.echo "Saving RT
Database"
oAB.SaveDataBase
MsgBox "Finished"
Else
msgbox "Can't Load RT Database"
End IF else
msgbox "Can't Load EOD Export.Afl" End
If Else MsgBox "Cant Load EOD
Database"End If
<SPAN
class=304335119-13042004>' destroy all objectsset fle = nothingset fls =
nothingset fldr = nothingset fso =
nothing
<SPAN
class=304335119-13042004>Set oAA = Nothingset oAB =
nothing
<SPAN
class=304335119-13042004><FONT
color=#0000ff>
From: chelnore [mailto:chelnore@xxxxxxxx]
Sent: Tuesday, April 13, 2004 3:32 PMTo:
amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] Re: Script to
automate exporting of EOD quotes and importing into Another DB - Need Help
with the oAB.Import.
tryFmtFleNam = "C:\Program
Files\Amibroker\formats\EOD_To_RT.Format"oAB.Import(0, CSV_FleNam
+".csv", FmtFleNam);also a single file would be faster, 20-30%
according to tj.curt
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|