string Extract = "AAPL";
string InName = "NBBO.csv";
string Format = "+,,,%m/%d/%Y,,,i7,f6,s8,,f1,f2,,,f4,f5";
string OutFormat = "%Y-%m-%d,f,f,f,f,f,f,i,i";
void main()
{
dataNew(1,0,0);
int Records = dataParse(1,Format,InName,Extract);
printf("n%d Records parsed",Records);
for(i=0; i<Records; i++) {
// fix expiry (is stored in wrong order)
int Expiry = dataInt(1,i,7);
int MMDD = Expiry/10000;
int YYYY = Expiry-MMDD*10000;
dataSet(1,i,7,YYYY*10000+MMDD);
// fix type (is stored as characters 'P' or 'C')
string Type = dataStr(1,i,8);
dataSet(1,i,8,ifelse(*Type == 'P',PUT,CALL));
// display progress bar and check [Stop] button
if(!progress(100*i/Records,0)) break;
}
dataSave(1,strf("History%s.t8",Extract));
}