LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only

Scripting Guide for Brain Newbies

  • 1.  Scripting Guide for Brain Newbies

    Employee
    Posted 02-01-2010 20:21

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Paolo_Andaya

    Hi everyone, I find the Brain software as a really powerful and insightful analytics tool. But I am just a total newbie on this program and it would really help a lot if I can get some general guidelines on coding/scripting per type of node. Let's say for inputing a user-delimited file, after I have selected a file/s from a directory, what are the other items I need to fill in, what to do to skip first record, data has header rows, etc. And the same for all the other nodes.

    I've been trying to follow the online help topics and quickstart guide. I'm just thinking there might be a general set of process I need to remember from selecting a node, editing the script, then output.

    I am greatly familiar with SQL. A comparison between the structure of Brain scripts and SQL scripts might help also. I just need a set of guidelines to remember when selecting a node and then editing the scripts to get my desired output.

    Thanks a lot


  • 2.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-02-2010 07:12

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    What kind of delimiters are in the file?

    If the file is a well-formed CSV file, (with comma delimiters) then you can just use CSVFile node.

    With CSVFile, you can either hard-code the file name in the File parameter, or you can add a DirectoryList node and then put 'FileName' (with single quotes) in the FilenamExpr parameter.

    Then you have an option. Either put a list of column heaaders into the FieldNames parameter, or the node will read the first record of the file and use that record as column headers.

    Check the help text for full explanations of the various options.


  • 3.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-02-2010 19:32

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Paolo_Andaya

    Thanks Stony. We intend to use the program for our tasks which means we will be dealing with several forms of data (CSV, pipe-delimited, etc.). Right now, we tried to import a pipe-delimited file. However, the way the data was extracted (from SAP) they used dashes to box in the headers (first row and third row of the file). I was able to use the DirectoryList node to pull in the files. But since the files are structured this way, importing failed due to the dashes in the first row (and probably would also in the third row). I was initially wondering if there's a way to skip rows when importing. At any rate, I ended up cleaning the file outside of the program to do a successful import.

    While we are on this topic, I was exploring the node functionalities and noticed that there's an option to change language and SQL is one of the recognized languages. Will SQL server scripting work for this?

    Thanks. My apologies if I am not making full sense. I am a total beginner with Brain and I would really like to have a full understanding of how it works.


  • 4.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-02-2010 23:41

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    This is perhaps not the "best" method, but here's one way that should work:

    Add DelimtedFile node to your graph.
    Take your Directory List output and connect it to the node.

    Edit the node. Go to the I/O tab and add a second output. This output will end up containing any "bad" records.

    Now, go to the server, open the source file with whatever editor you like, and copy the 2nd row.. the headers.

    Paste the header row into the FieldNames parameter, and change the pipe characters to commas.
    Then, for FieldDelimiter, enter the | pipe character (or whatever the file uses)
    Then, for RecordDelimiter, enter \n for newline


    Try running the node this way. It should produce (at least) two output records on the 2nd output pin.. they will happen to be the 1st and 3rd rows.

    =====
    Let's start with that much. As a later step, I can show you how to get MUCH more complicated.


  • 5.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-03-2010 00:05

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    Originally posted by: Paolo_Andaya
    					


    While we are on this topic, I was exploring the node functionalities and noticed that there's an option to change language and SQL is one of the recognized languages. Will SQL server scripting work for this?
    There are four nodes in Brain that provide CONNECTIVITY to a SQL-based server. But, they're not intended as a way to replace the coding that you would normally do in BrainScript, and if you limited yourself to just those four nodes, you would lose most of the power of Brain.

    In particular, the four nodes are designed to either read FROM or write TO an external database. They don't give you the same degree of freedom to manipulate data that BrainScript will give you.

    I'll give you a hint. Once you learn how to use the XREF and AGG nodes, you'll understand how SQL is actually more cumbersome than BrainScript.


  • 6.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-04-2010 18:27

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Paolo_Andaya

    Thanks Stony, we managed to get our data into Brain. However, we encountered some problems importing data with Chinese characters. Any thoughts on how to fix this?


  • 7.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-08-2010 13:17

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: aorlovsky

    Paolo,
    There are a couple guidelines for working with non-ASCII character sets.
    1. Use 'unicode', not 'string' as the column type for nonASCII data values.
    2. You cannot use Unicode as a column name.

    You may need to specify the "codepage" used by the BRAIN server. (See Preferences > General> Advanced in BRE.) You also may want to set your codepage preference in the BRD Viewer.

    Lots of detailed information about using Unicode in BRAIN and BRE can be found in the Brain Release Notes. It can be found in the section in the release notes covering Release 4.1.2. As of Release 4.1.5 you will find BRAINscript help contains all of that information as well.


  • 8.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-18-2010 01:38

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Paolo_Andaya

    Thanks guys for your replies.

    I have been trying to connect to MS SQL Server using th JDBC and DB Query nodes (not really sure which node should I use)

    For JDBC node, here's the error I encountered: "unable to load db driver: ..."
    Here are the parameters I entered:
    - SQL Query: select top 10 * from table_name
    - SQLQueryFieldBidings: <blank>
    - DBUSer: username
    - DBPassword: password
    - DBUrl: jdbc:microsoft:sqlserver://server_name
    - DBDriver: com.microsoft.sqlserver.jdbc.SQLServerDriver

    For the DB Query node, here's the error I encountered: "Data source name not found and no default driver specified"
    Here are the parameters I entered:
    - SQLQuery: select top 10 * from table_name
    - DBUser: username
    - DBPassword: password
    - DBService: server_name
    - DBInterface: ODBC

    Thanks in advance for your replies


  • 9.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 02-18-2010 10:18

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rabbott

    Assuming you're connecting to MS SQL Server, to use the JDBC nodes, you'll need to download and configure the drivers. Here are some quick steps:

    http://www.microsoft.com/downloads/d...displaylang=en

    Extract the files to your hard disk, under e.g. C:\Program Files\Microsoft SQL Server JDBC Driver\sqljdbc_2.0\enu

    Add the path to either "sqljdbc.jar" (for JRE 1.5 or lower) or "sqljdbc4.jar" (for JRE 1.6 or higher) to your Windows CLASSPATH variable under Control Panel > System > Advanced > Environment Variables.

    The DB Query nodes use ODBC and you'll need to configure a Data Source Name (DSN) under Control Panel > Administrative Tools > Data Sources (ODBC).

    Hope this information will suffice to get you going.


  • 10.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 12-14-2014 18:18

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: snbkumar

    Hi Tony/All,

    Can you guide the newbies (us) with a pdf that has comprehensive information about Brain Script? Something like JavaDocs for Java or MSDN.
    Without this its impossible to write meaningful code!

    Thanks,
    Bharath


  • 11.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 12-14-2014 18:26

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    Look in your LAE installation folder \docs
    There's a good bit of stuff in there.


  • 12.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 12-16-2014 18:24

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: snbkumar

    Hi Tony,

    Are you referring to BRAINScript Quick Reference.pdf? This is just 6 pages covering very basic stuff. Not even regex
    Need a comprehensive document like MSDN or JavaDocs. Please can you provide it? It would be very helpful.

    Thanks,
    Bharath


  • 13.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 12-17-2014 05:56

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: lnason

    In the Help menu, select "BrainScript Help"....this will take you to the top level of the most comprehensive BrainScript documentation that I'm aware of. These are housed in a set of HTML docs that are part of your LAE install.

    Also, if there is a specific BrainScript function you are curious about...type that function into the BrainScript editor....then, press the F1 key...this should take you directly to the documentation for that function. Note that your cursor will need to be positioned within or directly next to the function you just typed in when you press F1.

    Luke


  • 14.  RE: Scripting Guide for Brain Newbies

    Employee
    Posted 12-17-2014 15:36

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: snbkumar

    Hi Luke,
    Thank you. That helps. Shocking that I missed it!

    Regards,
    Bharath