Export csv script - need help with excluding Various Artists albums

Hi, I am really new at this and not a tech savvy guy at all so I've gone through a fair amount of documentation and export scripts to figure this out but feel that I am missing something pretty simple so thought I'd ask for help. Probably something that one of you experts will see in a minute.
I have my files organized by Artist/Album (c:/My Music/Artist/Album) and have a few compilations that are in a Various folder instead of Artist so that it is in Various/Album. Also, only the Various Artist albums have Various Artists under the field %albumartist% and the other albums have nothing in this field.
I am trying to generate a csv download that shows the data as follows:

      Album1     year
      Album2     year


     Album1     year
      Album2     year

and so on.
But when I use the script below it also includes the albums that are in the Various Artists folder under each artist which I am trying to exclude. So I wrote the if/neql part to exclude those from the Artist list, and wrote a separate if/eql condition to show those albums separately. I figure that I am doing something wrong with this conditional script so any help appreciated. Thanks.

$filename(C:\Album List.csv)

$loop(%_folder%) $if($neql(%albumartist%,Various Artists),
$if($eql(%albumartist%,Various Artists),
Build Date %_date%

Before digging deeper into the export script ...
at the first glance it looks like the script is not designed to create a standard CSV file format.

Maybe you want a script something like this ...

$filename($getEnv('USERPROFILE')'\Desktop\AlbumList.csv.txt',UTF-8) $loop(%ARTIST%,1)$loop(%ALBUM%,1)'"'$if2(%ALBUMARTIST%,%ARTIST%)'","'%ALBUM%'","'%YEAR%'"' $loopend()$loopend()


Thanks for the suggestion.
This does give me a list of Artist/Album/Year that I was looking for. However, my original problem remains, which is if I have an Artist who has a song in a compilation album (these songs are tagged with the Artist under %Artist% and 'Various Artists' under %albumartist%) it shows up in this list for every song by a different artist and I'd like to exclude them from this list (and ideally create a separate list of just these albums). See example of report below:

Ahmad Jamal The Awakening 1997
Ahmad Jamal The Essence Part 1 1995
Various Artists The House That Trane Built (4 Disc) 2006

So, here, there was a song by Ahmad Jamal in the album The House That Trane Built and that entry appears for every different artist on that album.

Thanks for the help.

Maybe you want a script something like this ...

01: $filename($getEnv('USERPROFILE')'\Desktop\AlbumList.csv.txt',UTF-8)

02: $loop($if2(%ALBUMARTIST%,%ARTIST%),1)$loop(%ALBUM%,1)'"'$if2(%ALBUMARTIST%,%ARTIST%)'","'%ALBUM%'","'%YEAR%'"'
03: $loopend()$loopend()


Great, that does the trick. Thanks a lot! I really appreciate your input.