[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: How to sort lines in a file



PureBytes Links

Trading Reference Links

Hello Herman
i don't know if you interesting about Osaka dll but i just made one for you 
like your sample
you can short any column you wish . And it is fast and inside in ALF

----------- sample --
AAAA,-123,12.3,12345,122,223
AADD,1231,12.31,123451,1221,2231
BBCC,123,12.3,12345,122,223
AACC,123,12.3,12345,122,223
AABB,-124,13.3,12345,122,223
AAWL,123,12.3,12345,122,223
------------------
--------------code-----------------
"IMPORT/SORT/EXPORT -----";
osInitialize();
table3 = osTabCreate();
osTabAddColumn( "ticker column", 2, table3,strSize =8 );   // strSize 
optional specifies Max. length of text field)
osTabAddColumn( " second column", 1, table3 );
osTabAddColumn( " column 3 ", 1, table3 );
osTabAddColumn( " column 4 ", 1, table3 );
osTabAddColumn( " column 5 ", 1, table3 );

// MUST create and define columns in  the table prior to importing !
osTabImport("TestLoad.txt", ",", table3 );

osTabSort(table3,0); // SORT BY FIRST COLUMN alphabetically
// osTabSort(table3,1 ); // SORT BY second COLUMN

Output = "";
for( i = 0; i < 100; i++ )
{
   Output = Output  + osTabGet( i, 0, table3 ) + ", " +  osTabGet( i, 1 , 
table3 ) + ", " +  osTabGet( i, 2 , table3 ) +", " +  osTabGet( i, 3 , 
table3 ) + ", " +  osTabGet( i, 4 , table3 ) + "\n";
}

Output;

osTabExport( "TestSave.txt", ",", table3 );  // saved in Amibroker directory
osTabDelete( table3 );          // deletes a table and frees memory 
allocated by it.

--------end code-----------------------



At 12:44 AM 23-08-2008, you wrote:

>csv lines, each line terminated with a CR:
>
>
>AAPL,123,12.3,12345,122,223
>
>AA,1231,12.31,123451,1221,2231
>
>etc...
>
>
>actually the file is created from afl so I can give it any format I want 
>however the above is easy to import into excel for checking. It would be 
>nice to be able to specify the column to sort by, however i can swap 
>columns easy enough.
>
>
>I am running Windows XP Home. It is essential I can call the routine from 
>afl.
>
>
>thanks for the input!
>
>
>herman.
>
>
>
>
>
>
>
>
>
>Friday, August 22, 2008, 4:18:27 PM, you wrote:
>
>
> > What is the format of your file (e.g. raw text, csv, xml, html, etc.)?
>
> > Is the data column based and you want to sort by column (either named
>
> > or positional), or do you just want a vanilla alphabetical sort on the
>
> > raw text?
>
>
> > Giving a few sample lines from the file would be helpful.
>
>
> > Mike


------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/