Quantcast
Viewing all articles
Browse latest Browse all 16689

Difficulty with Javascript and txt input

I am newish to Pentaho and I've been working on writing some Javascript that will take in an inconsistent text file (see related post: http://forums.pentaho.com/showthread...al-file-format) and pull out only the data I need.

Right now, I am having difficulty using Javascript to split the incoming file on the new line character. I assumed that just using something like this would work:
Code:

var parts = someField.split("\\n");
Unfortunately, it was unsuccessful (the whole file was still returned as one string). After some searching on the forums I found slightly different syntax, so I tried:
Code:

var parts = someField.getString().split("\\n");
I had the same result - the string didn't split on new lines. After some more searching, I found a suggestion that someone posted where they defined "\n" as a variable in a job and then used it in the Split Field to Rows step so I tried that, but still had no success. As an aside, I have been able to successfully split on whitespaces/etc., just not new lines.

How can I split the file to rows based on the new line character?

(As an aside, it would be awesome if the Split Field to Rows step had a couple optional check boxes/radio buttons for common "special" delimiters under the Delimiter field, such as new line and possibly tab...)

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>