How to save datarecordnumber to csv ?
Im trying to add a datarecordnumber to my csv as part of the file writer, but I haven't been able to get it to work. Can someone please suggest some code that will make it possible to save the datarecordnumber? Thanks in advance for any help!
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() );
}
Thank you but I meant the datarecord number from screenscraper
Thank you but I mean the datarecord number generated by screenscraper which is displayed in the log. The API for screenscraper says it is available with some derivative of this command
but when I use something this in my csv writer script which is in my previous posting
I get error messages indicating that my syntax is incorrect.
I do like your code snippet though and it actually answers another question I had and may be a more elegant solution for my original request, so thanks very much! Do you (or anyone else) have any tips or answers on how to implement the dataSet.getDataRecord so that it will record the dataRecordNumber?
Have a script before
Have a script before extractor pattern is applied
And in your writ to file script
... and of course a line to write that value.
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