Error in method invocation-Script doesn't write to data file

I'm pulling the data I want, but I can't write it to a data file.

Here is my Script (I'm not a programmer, but I can normally work my way around with examples):

/ Output a message to the log so we know that we'll be writing the text out to a file.
session.log( "Writing data to a file." );

// Create a FileWriter object that we'll use to write out the text.
out = new FileWriter( "estellamntrnchre.csv" );

// Write out the text.
out.write(

session.getVariable( "mls" ),
session.getVariable( "Status" ),
session.getVariable( "Address" ),
session.getVariable( "Fe" ),
session.getVariable( "Trans_Date" ),
session.getVariable( "sqft" ),
session.getVariable( "List_Price" )
);

// Close the file.
out.close();

Here is the error:

Writing data to a file.
Estrella Mnt Rnch Homes: An error occurred while processing the script: AZRE Write Extracted Data To File
Estrella Mnt Rnch Homes: The error message was: Error in method invocation: Method write( java.lang.String, null, null, null, null, null, null ) not found in class'java.io.FileWriter' : at Line: 8.
Processing scripts after scraping session has ended.
Scraping session finished.

Anything jump out at anyone or any ideas? Any help would be appreciated. Thanks!

Error in method invocation-Script doesn't write to data file

Hi,

In answer to your question, it's tough to know how to address this without knowing what's confusing to you. Not knowing your programming background, it's hard to know where the gaps in your knowledge might be. It may be best for you to look carefully through our third tutorial (here), then ask more specific questions.

On your second question, the method I gave for writing the data to a file simply gives you more control. If you want something quick and simple that writeToFile method would be a better option.

Kind regards,

Todd

Error in method invocation-Script doesn't write to data file

I don't think I should have the "save session in variable" on in the token (which I did). However, with it on for the tokens, when I use the code you provided only one record get's written. If I set the "session variables" to off, then no records get written and I get (null, null, etc..) errors.

I did find (in tutorial 3 which I hadn't finished previously) I could use this:

dataSet.writeToFile( "estrlamntrnchre.txt" )

which worked ang gave me the data I needed. Which is great, but since I'm a newbie I'd like to understand 1) why the other script is not working and 2) maybe an example of when I'd use a script similar to that you provided vs the simple (dataSet.writeToFile( "estrlamntrnchre.txt" )) script.

Thanks for your help, I'm looking forward to really learning how to use this software.

Error in method invocation-Script doesn't write to data file

Hi,

Try changing this:

out.write(

session.getVariable( "mls" ),
session.getVariable( "Status" ),
session.getVariable( "Address" ),
session.getVariable( "Fe" ),
session.getVariable( "Trans_Date" ),
session.getVariable( "sqft" ),
session.getVariable( "List_Price" )
);

to this:

out.write("\"" + session.getVariable( "mls" ) + "\",");
out.write("\"" + session.getVariable( "Status" ) + "\",");
out.write("\"" + session.getVariable( "Address" ) + "\",");
out.write("\"" + session.getVariable( "Fe" ) + "\",");
out.write("\"" + session.getVariable( "Trans_Date" ) + "\",");
out.write("\"" + session.getVariable( "sqft" ) + "\",");
out.write("\"" + session.getVariable( "List_Price" ) + "\",");

Kind regards,

Todd Wilson