I am trying to run the below formula on a column with 100 million rows to calculate the moving average.Could you please suggest an JMP11 alternative for Col Moving Average
Col Moving Average( :x, 1, 9999999, 0 ) is not supported by JMP11.
Please find below the code I have tried:
NamesDefaultToHere(1);
// Use a function to open a .CSV file: Given the path to such a file, returns a reference to the resulting table
openMyCSV =
function({path2File}, {Default Local},
dt = Open(
path2File,
columns(
New Column( "column 1", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "items", Numeric, "Continuous", Format( "Best", 12 ) )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 0 ),
Column Names Start( 1 ),
Data Starts( 1 ),
Lines To Read( "All" ),
Year Rule( "20xx" )
)
)
);
dt = New Table( "My data file");
dt << New Column( "cc", Character, width( 40 ) );
dt << New Column( "MovAvgMean", Numeric );
dt << New Column( "MovAvgMax", Numeric );
// Put all the .csv files to process into a list
dir = Pick Directory(
"Directory containing your csv files",
"C:\Users\xxx\Documents\test\"
);
files = Files In Directory( dir );
For( f = N Items( files ), f >= 1, f--,
If( !Ends With( Uppercase( files[f] ), ".CSV" ),
Remove From( files, f )
)
);
// Process each file - Incomplete!
For( f = 1, f <= N Items( files ), f++,
thisTable = openMyCSV( dir || files[f] );
thisTable << New Column( "x",
Numeric,
Continuous,
Formula( (87 *:items)-(0.03998113) ));
thisTable << New Column( "av", Numeric, Continuous, Formula( Col Moving Average( :x, 1, 9999999, 0 ) ) );
// This will insure that all formula processing is complet before the next statement is run
thisTable << run formulas;
FileName = files[f];
// Add the summary statistics to the summary table
dt << Add Rows( 1 );
dt:cc[N Rows( dt )] = FileName;
dt:MovAvgMean[N Rows( dt )] = Col Mean( thisTable:x );
dt:MovAvgMax[N Rows( dt )] = Col Max( thisTable:x );
Close( thisTable, nosave );
);
9