Hi Sven,

Arg, you got us :-P
Shame on us!
You are completely right that we could have done that in Pharo.
But,��Zhi��is working since mont on doing realistic robotics simulation on the cluster of the EMD.
The goal is to use the SAME code both in simulation and in the real robots.
For doing this, he is writing a lot (a LOT) of BASH scripts to automatically prepare simulations on the cluster nodes.
Since he is not really fluent in Pharo and since it involves so much system scripting, he is doing it in BASH.
I suspect that he took the least resistant path to code the csv to html ...

Anyway, at some point we will move from this first prototype to another one so involve Pharo deeper using PhaROS and then we will have more Pharo in the loop ;-)

Cheers,

#Luc

2014-09-18 10:28 GMT+02:00 Sven Van Caekenberghe <sven@stfx.eu>:
Hi,

Today I came across some bash code on a web page that loves Smalltalk, ah the horror ;-)


The goal is to make it easier to look at CSV data, for which a conversion to HTML was done. To just look at CSV data in a nice tabular form, we do not have to leave Pharo at all.

MultiColumnListModel new��
�� items: (FileLocator desktop / 'test.csv' readStreamDo: [ :in |��
�� �� �� �� �� �� (NeoCSVReader on: in) emptyFieldValue: ''; upToEnd ]);
�� displayBlock: [ :x | x ];
�� title: 'CSV Data';
�� openWithSpec.

Which results in this nice window:


To do a conversion to HTML, debugging the code in Pharo should be preferable to doing the same with bash & sed (for most of us anyway).

FileLocator desktop / 'csv.html' writeStreamDo: [ :out | | reader |
�� out << '<html><head><title>CSV Data</title></head><body><table border=1>'.
�� reader := NeoCSVReader on: (FileLocator desktop / 'test.csv') readStream.
�� reader emptyFieldValue: ''.
�� out << '<tr bgcolor=silver>'.
�� reader readHeader do: [ :each | out << '<th>'; << each; << '</th>' ].
�� out << '</tr>'.
�� reader do: [ :each |
�� �� out << '<tr>'.
�� �� each do: [ :td | out << '<td>'; << td; << '</td>' ].
�� out << '</table></body></html>'.
�� reader close ].

Which gives the following output:

NeoCSVReader is way more powerful in interpreting CSV files than a simple sed one-liner. Doing the same for a collection of files is easy. Maybe a little browser could even be written. Who knows, maybe Doru will add another tool to GT (TableViewer class>>#openStructuredOn: would do the trick I guess) ;-)

Sven

PS: The bash script was actually quite well written, even I could read/understand it. Thanks for sharing, it was the inspiration to do this little hack.