Save validator messages (results) to Excel or csv?

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
armplinker
Rank 0 - Newcomer
Rank 0 - Newcomer
Posts: 6
Joined: Mon Oct 08, 2012 9:48 am

Save validator messages (results) to Excel or csv?

Post by armplinker » Wed Jan 27, 2016 11:11 am

I am generating the html report fine, and it is lovely, :D but what I would also like is to generate a 'hit list' of errors (classified) which I can bring into Excel or another tool and just work down to clear all the problems....

Is there a way to emit the messages (with the report URLs as a column, I guess) in a single Excel sheet / table?

Thank you.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3451
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Save validator messages (results) to Excel or csv?

Post by Albert Wiersch » Wed Jan 27, 2016 12:05 pm

Hello,

You could try using user functions to create a CSV file. There's some example code here:
https://www.htmlvalidator.com/v160/docs ... eadded.htm

Basically, you can put this code in a text file (recommend a ".cfg" extension):

Code: Select all

function onMessageAdded() {
 $csvfilearray[]=
  '"'+getValueString(5)+'",'
  +$oma_message.typetext+','
  +$oma_message.subtypetext+','
  +$oma_message.lineloc+','
  +$oma_message.charloc+','
  +$oma_message.id+',"'
  +replaceStringCase($oma_message.text,'"','""')+'","'
  +replaceStringCase($oma_message.sourcehighlight,'"','""')+'","'
  +replaceStringCase(getSourceLine($oma_message.lineloc),'"','""')+'"';
}

function onEndedValidation() {
 writeFile('T:\validation_output.csv','csvfilearray',1); // append
}
Then specify that text file as a user functions file in the Validator Engine Options, 'Validator Engine->Config File' page.

Notes:
* You'll need to update the filename in the code above (it's currently coded to 'T:\validation_output.csv').
* You'll need to enable potentially destructive functions in the 'Config File' options page so the writeFile() function works
* Every document you validate (including in the Batch Wizard) will then append to the file you specify
* You'll have to manually delete the file to clear/reset it or it will keep appended to it (though you could write a Batch Wizard user function to delete it automatically when you run a new Batch Wizard job).

Hope this helps and gets you started. Please let me know how it goes!
Image
Albert Wiersch

Post Reply