jasmineRepo / JAS-mine-core

JAS-mine maintains and develops the JAS simulation platform, a discrete-event tool-kit for agent-based and dynamic microsimulation modelling. This repository contains the core libraries. See www.jas-mine.net for more details.
2 stars 5 forks source link

CSV writer clarifications #22

Closed vkhodygo closed 2 years ago

vkhodygo commented 2 years ago

@pbronka

I have a question regarding the following section of the code:

https://github.com/jasmineRepo/JAS-mine-core/blob/fa07b21137cbdd71af841354d2bdf0aa83bd9b3c/microsim-core/src/main/java/microsim/data/ExportCSV.java#L171-L176

I saw your recent comments there and I hope you're familiar enough with this part.

What's the point of adding anything to the buffer here when the file to write to doesn't exist?

pbronka commented 2 years ago

@pbronka

I have a question regarding the following section of the code:

https://github.com/jasmineRepo/JAS-mine-core/blob/fa07b21137cbdd71af841354d2bdf0aa83bd9b3c/microsim-core/src/main/java/microsim/data/ExportCSV.java#L171-L176

I saw your recent comments there and I hope you're familiar enough with this part.

What's the point of adding anything to the buffer here when the file to write to doesn't exist?

I think the answer lies in the following lines: https://github.com/jasmineRepo/JAS-mine-core/blob/fa07b21137cbdd71af841354d2bdf0aa83bd9b3c/microsim-core/src/main/java/microsim/data/ExportCSV.java#L122-L127

So if the file doesn't exist, it is first created and then the bufferWriter writes to it, starting with: https://github.com/jasmineRepo/JAS-mine-core/blob/fa07b21137cbdd71af841354d2bdf0aa83bd9b3c/microsim-core/src/main/java/microsim/data/ExportCSV.java#L128-L133

Not the best naming convention, perhaps...