I have written a macro in JavaScript that uses iMacros (FireFox addon) to login to a website and extract a table. Eventually I want the data in a JavaScript array so that I can loop over it. iMacros extracts the table in a csv format. I have tried [Papa Parse][2] on the data (using the demo on its website) and the data was very usable after parsing. So I would like to incorporate PapaParse into my JavaScript code that uses iMacros. How would I do this?
I have tried pasting into my code the JavaScript code that is in this file: papaparse.min.js. This is the file the Papa Parse documentation says that you need for production. When I ran my JavaScript I got a reference error stating that "Papa" is not defined.
I am not trying to develop my own website. I am just trying to collect data from a table at another website. So I don't have an index.html file or any css files in my project.
Can I use Papa Parse with just JavaScript and iMacros?
Here is my code (papaparse.min.js excluded for brevity):
function test() {
var macro;
macro ="CODE:";
macro +="SET !ERRORIGNORE YES" + "\n";
macro +="URL GOTO=https://en.wikipedia.org/wiki/United_States_presidential_election,_2016 " + "\n";
macro +="TAG POS=1 TYPE=TABLE ATTR=TXT:* EXTRACT=TXT " + "\n";
var returnCode = iimPlay(macro);
var table = iimGetLastExtract();
// Parse csv string
// var data = Papa.parse(table);
var document = window.document;
// contents of Papaparse.min.js inserted here, omitted for brevity
alert(window.Papa);
alert(JSON.stringify(window.Papa);
}
[1]: https://addons.mozilla.org/en-US/firefox/addon/imacros-for-firefox/
[2]: http://papaparse.com/