Need help saving dataRecordNumber to CSV
Hello,
I'm still unable to save the dataRecordNumber that screen scraper generates as it scrapes to CSV. I'm hoping someone can provide me with the code to do this.
Here is my csv writer:
FileWriter out = null;
try
{
session.log( "Writing data to a file." );
// Open up the file to be appended to.
out = new FileWriter( "csvfile.txt", true );
// Write out the data to the file.
out.write( session.getVariable( "PAGE" ) + "\t" );
out.write( dataRecord.get( "VARIABLE1" ) + "\t" );
out.write( dataRecord.get( "VARIABLE2" ) + "\t" );
out.write( dataRecord.get( "VARIABLE3" ) + "\t" );
out.write( dataRecord.get( "VARIABLE4" ) + "\t" );
out.write( dataRecord.get( "VARIABLE5" ) );
out.write( "\n" );
// Close up the file.
out.close();
}
catch( Exception e )
{
session.log( "An error occurred while writing the data to a file: " + e.getMessage() );
}
try
{
session.log( "Writing data to a file." );
// Open up the file to be appended to.
out = new FileWriter( "csvfile.txt", true );
// Write out the data to the file.
out.write( session.getVariable( "PAGE" ) + "\t" );
out.write( dataRecord.get( "VARIABLE1" ) + "\t" );
out.write( dataRecord.get( "VARIABLE2" ) + "\t" );
out.write( dataRecord.get( "VARIABLE3" ) + "\t" );
out.write( dataRecord.get( "VARIABLE4" ) + "\t" );
out.write( dataRecord.get( "VARIABLE5" ) );
out.write( "\n" );
// Close up the file.
out.close();
}
catch( Exception e )
{
session.log( "An error occurred while writing the data to a file: " + e.getMessage() );
}
I have tried using this code in the CSV writer, but I get errors.
out.write( dataSet.getDataRecord( dataRecordNumber ) + "\t" );
The api says it is possible, but I can't figure out how to implement it... can anyone help? Sorry to post this again but my previous thread got a little sidetracked.
Can you give me the link to
Can you give me the link to where you see it in the API? I know I looked into this before, I couldn't find that the DataSet was indexed.
Here is the link from the API
Thanks for looking this over. Perhaps I am misunderstanding what I'm reading?
bcb,In order to retrieve the
bcb,
In order to retrieve the current index of a DataRecord object you're going to need to already be iterating through all available records.
This link shows you an example of how you can iterate over DataRecords and how you can reference the current index in your code.
Hope that helps,
Scott