Skip to content

hhzl/Cuis-NeoCSV

Repository files navigation

Cuis-NeoCSV

Read and write CSV converting to or from Smalltalk objects.

Description from: https://github.com/svenvc/docs/blob/master/neo/neo-csv-paper.md

Basically, NeoCSV deals with a format that

  • is text based (ASCII, Latin1, Unicode)
  • consists of records, 1 per line (any line ending convention)
  • where records consist of fields separated by a delimiter (comma, tab, semicolon)
  • where every record has the same number of fields
  • where fields can be quoted should they contain separators or line endings

https://github.com/svenvc/docs/blob/master/neo/neo-csv-paper.md

The port was done from from http://www.smalltalkhub.com/#!/~SvenVanCaekenberghe/Neo.

Now on github: https://github.com/svenvc/NeoCSV

To do: find out if there are changes in the meantime that need to be ported also.

Log of port of 2015 version

Name: Neo-CSV-Core-SvenVanCaekenberghe.22 Author: SvenVanCaekenberghe Time: 10 May 2015, 10:07:22.199998 pm

Name: Neo-CSV-Tests-SvenVanCaekenberghe.19 Author: SvenVanCaekenberghe Time: 10 May 2015, 10:07:41.797345 pm

#5

For Cuis version Cuis4.2-2243.image

Changes by Hilaire Fernandez to bring it up to Cuis 7 have been merged.

Section 1 -- Initial port without fixes

File out from Pharo 4.0 / File in into Cuis

  1. In Pharo 4.0 (May 2015) load NeoCSV package (one-click).

  2. File out class packages

    • Neo-CSV-Core
    • Neo-CSV-Tests
  3. Rename files to

    • Neo-CSV-Core-orig.st
    • Neo-CSV-Tests-orig.st
  4. In Cuis open File List.

  5. Install package SqueakCompatibility.pck.st

  6. Do the following string replacements in the original files

    Replace codePoint with unicodeCodePoint

    Replace String crlf with String crlfString

    Replace String cr with String crString

    Note: there is a space after 'cr' and 'crString'

    Replace String lf with String lfString

  7. Get code browser on 'Neo-CSV-Core-orig.st'

  8. File in classes in the following order

    • NeoNumberParser
    • NeoCSVReader
    • NeoCSVWriter
  9. Open 'World Menu'

  10. Choose 'Open'

  11. Choose 'Installed Packages'

  12. Click on 'Create Package'

  13. Type package name 'Neo-CSV-Core'

  14. Enter a description. Include reference to source of the ported file. Port of Neo-CSV-Core-SvenVanCaekenberghe.22

  15. Click on 'Save'

  16. Open File list on 'Neo-CSV-Tests.st'

  17. Get a code browser on 'Neo-CSV-Tests.st'

  18. File in class #NeoCSVTestObject

  19. File in NeoNumberParserTests

  20. File in NeoCSVReaderTests

  21. File in NeoCSVWriterTests

  22. Do not file in class #NeoCSVBenchmark as it gives a waring Wthat ZnBufferedWriteStream and ZnBufferedReadStream are not defined.

  23. Created a package 'Neo-CSV-Tests' Description: Port of Neo-CSV-Tests-SvenVanCaekenberghe.19

Unit tests

Run SUnit tests on code which was filed in:

Result is that 51 out of 52 tests passed.

Section 2 -- Analysis

The following test fails

testHexadecimalIntegers
self assert: (NeoNumberParser parse: '7B' base: 16) equals: 123.
self assert: (NeoNumberParser parse: '7b' base: 16) equals: 123.
self assert: (NeoNumberParser parse: '-7B' base: 16) equals: -123.
self assert: (NeoNumberParser parse: '-7b' base: 16) equals: -123.
self assert: (NeoNumberParser parse: '0' base: 16) equals: 0.

The test does not fail if the code is changed to

 testHexadecimalIntegers
self assert: (NeoNumberParser parse: '7B' base: 16) equals: 123.
"self assert: (NeoNumberParser parse: '7b' base: 16) equals: 123."
self assert: (NeoNumberParser parse: '-7B' base: 16) equals: -123.
"self assert: (NeoNumberParser parse: '-7b' base: 16) equals: -123."
self assert: (NeoNumberParser parse: '0' base: 16) equals: 0.

Section 3 -- Code changes

Fix code as described under section 2 -- analysis

Result after fixing

52 out of 52 tests are green.

Conclusion -- Port status

  • The port is OK.

  • The package requires SqueakCompatibility.pck.st to be loaded and at least Cuis4.2-2243.image

  • The following changes were applied to the code before file in

    Replace codePoint with unicodeCodePoint

    Replace String crlf with String crlfString

    Replace String cr with String crString

    Note: there is a space after 'cr' and 'crString'

    Replace String lf with String lfString

  • Class #NeoCSVBenchmark has not been ported.

  • Major port is done as of May 2015.

  • Documentation