Hi all,
I have a project where I need to read data that is in an external file, that file will be in CSV or XML format. I don't know how to do this nor if it is possible in Etoys? Who can give ma a hand with a detailed explanation? Thank you,
All the best, Luís Valente www.valente.org.pt
That is very much possible, but you must use Smalltalk, the language Etoys are built from.
Karl
On Mon, Apr 29, 2013 at 10:51 PM, Luis Valente is.valente@gmail.com wrote:
Hi all,
I have a project where I need to read data that is in an external file, that file will be in CSV or XML format. I don't know how to do this nor if it is possible in Etoys? Who can give ma a hand with a detailed explanation? Thank you,
All the best, Luís Valente www.valente.org.pt
Hi Luis,
For CSV files you can see that Physical Etoys includes Skeleton with a few changes that allow a spreadsheet to import/export csv data from external files. If you want to use that in Etoys you can load this file: http://source.squeak.org/etoysinbox/Skeleton-Richo.10.mcz and look for the "data i/o" category on the Skeleton spreadsheet.
For XML, I'm afraid you'll have to get your hands dirty and write some smalltalk code :) I don't know your smalltalk knowledge, but here it's a simple example that might help you get started, let me know if you need more help:
xml := XMLDOMParser parseDocumentFrom: ' <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don''t forget me this weekend!</body> </note>' readStream. xml explore.
Cheers, Richo
On Mon, Apr 29, 2013 at 5:51 PM, Luis Valente is.valente@gmail.com wrote:
Hi all,
I have a project where I need to read data that is in an external file, that file will be in CSV or XML format. I don't know how to do this nor if it is possible in Etoys? Who can give ma a hand with a detailed explanation? Thank you,
All the best, Luís Valente www.valente.org.pt
It may not be obvious how to call Smalltalk code from Etoys. It's rather simple.
Any object's script can be changed to Smalltalk text and then more Smalltalk code can be added and saved there.
For example, attached are photos of the button script that moves a Star object to a position on the World coordinates. [image: Inline image 1]
Selecting the White menu button in the top right corner you get this menu:
[image: Inline image 2]
Choose "show code textually" and you get the Smalltalk equivalent.
[image: Inline image 3]
Now you can replace the Smalltalk code that moves the star with the Smalltalk code you want to execute to load the CSV file ... into some text object for example.
- Darius
On Tue, Apr 30, 2013 at 12:59 PM, Ricardo Moran richi.moran@gmail.comwrote:
Hi Luis,
For CSV files you can see that Physical Etoys includes Skeleton with a few changes that allow a spreadsheet to import/export csv data from external files. If you want to use that in Etoys you can load this file: http://source.squeak.org/etoysinbox/Skeleton-Richo.10.mcz and look for the "data i/o" category on the Skeleton spreadsheet.
For XML, I'm afraid you'll have to get your hands dirty and write some smalltalk code :) I don't know your smalltalk knowledge, but here it's a simple example that might help you get started, let me know if you need more help:
xml := XMLDOMParser parseDocumentFrom: '
<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don''t forget me this weekend!</body> </note>' readStream. xml explore.
Cheers, Richo
On Mon, Apr 29, 2013 at 5:51 PM, Luis Valente is.valente@gmail.comwrote:
Hi all,
I have a project where I need to read data that is in an external file, that file will be in CSV or XML format. I don't know how to do this nor if it is possible in Etoys? Who can give ma a hand with a detailed explanation? Thank you,
All the best, Luís Valente www.valente.org.pt
There's also a simple CSV parser on SqueakSource: SqueakSource project page http://www.squeaksource.com/CSV.html
After you import it into your image, be sure to save that image file and distribute it to all your students instead of the standard .image file.
___
Attached are the files you'll need.
Drag and drop the SUnit-Kernel.st file into your Etoys image first. Select "load" from the popup menu. Drag and drop the CSV-JohnnyT.10.mcz file next into your Etoys World. Select "load" from the popup menu. Save your image with the Alt-, menu. (Hold down alt and the comma). Select "do..." in the menu. Select "Smalltalk saveAsNewVersion" in the "Common Requests" menu.
Remove the version number added to the generated file etoys.1.image and etoys.1.changes and replace your original etoys.image and etoys.changes files and distribute those to your students as part of your modified Etoys distribution.
Now you can access Smalltalk from Etoys tiles as I mentioned above.
Something like:
| pal csvParser csvMorph rowMorph | pal := (FileDirectory on: 'C:') / 'Pal' / 'data' / 'InFile'.
csvParser := CSVParser parse: (FileDirectory default readOnlyFileNamed: (pal pathName, '\Pal.INV.csv')). csvMorph := AlignmentMorph newColumn. csvMorph borderWidth: 1. csvParser rows do: [:row | rowMorph := AlignmentMorph newRow. rowMorph borderWidth: 1. row do: [:text | rowMorph addMorph: (((RectangleMorph new) addMorph:((StringMorph contents: text) borderWidth: 1)) borderColor: Color black). ]. csvMorph addMorph: rowMorph copy. ]. csvMorph openCenteredInWorld.
Hi All, It's wonderful all the help I got. Thank you. Skeleton solves my needs for now! And my knowledge about smalltalk isn't enough to go further with xml in Etoys, although I think it could be a nice matter to learn Cheers, Luis
2013/4/30 Darius Clarke socinian@gmail.com
It may not be obvious how to call Smalltalk code from Etoys. It's rather simple.
Any object's script can be changed to Smalltalk text and then more Smalltalk code can be added and saved there.
For example, attached are photos of the button script that moves a Star object to a position on the World coordinates. [image: Inline image 1]
Selecting the White menu button in the top right corner you get this menu:
[image: Inline image 2]
Choose "show code textually" and you get the Smalltalk equivalent.
[image: Inline image 3]
Now you can replace the Smalltalk code that moves the star with the Smalltalk code you want to execute to load the CSV file ... into some text object for example.
- Darius
On Tue, Apr 30, 2013 at 12:59 PM, Ricardo Moran richi.moran@gmail.comwrote:
Hi Luis,
For CSV files you can see that Physical Etoys includes Skeleton with a few changes that allow a spreadsheet to import/export csv data from external files. If you want to use that in Etoys you can load this file: http://source.squeak.org/etoysinbox/Skeleton-Richo.10.mcz and look for the "data i/o" category on the Skeleton spreadsheet.
For XML, I'm afraid you'll have to get your hands dirty and write some smalltalk code :) I don't know your smalltalk knowledge, but here it's a simple example that might help you get started, let me know if you need more help:
xml := XMLDOMParser parseDocumentFrom: '
<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don''t forget me this weekend!</body> </note>' readStream. xml explore.
Cheers, Richo
On Mon, Apr 29, 2013 at 5:51 PM, Luis Valente is.valente@gmail.comwrote:
Hi all,
I have a project where I need to read data that is in an external file, that file will be in CSV or XML format. I don't know how to do this nor if it is possible in Etoys? Who can give ma a hand with a detailed explanation? Thank you,
All the best, Luís Valente www.valente.org.pt
squeak-dev@lists.squeakfoundation.org