More updates to CSV class

Made some improvements to the CSV Class.

  • Generates a Clarion FILE, GROUP, or QUEUE structure
  • Improved auto-sizing of listbox columns (when using listbox).
  • Added another example for filling your own queue

Here’s the entire program for filling the queue and viewing it.:


MyQueue                              QUEUE  
id                                     STRING(4)
first_name                             STRING(13)
last_name                              STRING(18)
email                                  STRING(39)

Window WINDOW('Loading a queue from CSV'),AT(,,315,224),CENTER,GRAY,FONT('Segoe UI',9)
    LIST,AT(2,2,311,220),USE(?LIST1),FROM(MyQueue),FORMAT('26L(2)|M~ID~C(2)52L(2' & |
        ')|M~First Name~C(2)53L(2)|M~Last Name~C(2)20L(2)|M~Email~C(2)')

CSV  JSCSVParseClass



  IF NOT CSV.LoadFile('.\SampleData\CSVdemo2.Comma.CRLF.csv')
    MESSAGE('Did not load file.')
  LOOP Ndx = 1 TO CSV.GetRowCount()
    MyQueue.ID         = CSV.GetCellValue(Ndx,1) 
    MyQueue.first_name = CSV.GetCellValue(Ndx,2)
    MyQueue.last_name  = CSV.GetCellValue(Ndx,3)      = CSV.GetCellValue(Ndx,4)
1 Like

Will add support for escaped double-quotes sometime soon.

Updated the readme:

Was going to leave it alone for a while, but made several more improvements. Added GetMemoryUsed() to attempt to calculate the overhead memory that is used up.

Also added GetColumnNumber, which will attempt to find a column based on its name (or part of its name).

Added a status bar to the main demo & ST demo.

Good stuff Jeff. Thanks.

I would like to contribute on the support of escaped double quotes. I forked the project to make some changes, then you could look at them to analyse the diff and join them on your project if you like, what do you think?

I see you made some little changes some minutes ago… do you have more changes pending?

Hi Federico - Cool, that would be great. :slight_smile:
I have no changes pending. Go for it.

Thank you.

Thanks Jeff. I’ve just uploaded the modified files and comments on readme.


Neat-o! I will give it a better look this weekend, but I like what I see. Thanks so much!

1 Like

Hi Federico - That is pretty dang nifty. So far, it’s working well. It parsed this out perfectly inside one column:

"Now is the ““time”” for all good folks to come to the ““aid”” of their solar ““system””"
Now, is the “time”, for all good folks to come to the “aid” of their solar "system"
Thanks a whole lot. :slight_smile:
I’ll try to do some more testing next weekend or so.

Thanks Jeff,
I’ve added a method to calculate the cell length without creating a new string, in case it is needed for performance, although I didn’t measured it.

This Diff

1 Like

I have included Federico’s mods in my repo. He really made some nice improvements.

Supports escaped quotes now and other stuff as mentioned at the bottom of the readme.

Thanks again, Federico.

Hi Jeff, you are welcome, it is a pleasure to do a small contribution to a bigger one, thanks.