I'm a relative newcomer to Groovy/Java and have a question about efficiently outputting data to a .csv file. Basically, as my simulation model runs, I save key information in a list. For example, I track tasks undertaken by agents, so I save ID, duration, and action. I end up with a long list that is divisible by 3, but has a number of elements in it. I use the following code to output it into a 3 column csv file:
Essentially, I take the first three elements of my list, create a list that represents a row, add it to a list of maps, and then write to the csv file one row at a time. It produces perfect output, but it takes forever (these lists have thousands of elements in them). It's much faster to just write the original list to CSV, but then I end up with one row rather than a three-column table. I can always process the data in something that I'm more familiar with, like Stata, but I figured I'd ask about more efficient ways to do this. Thanks in advance for your thoughts!