CSV still used

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply

A CSV class API would be helpful

Yes
4
50%
No
4
50%
 
Total votes: 8

alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

CSV still used

Post by alex.barylski »

A few years back I did alot of CSV conversion and such for a guy I was working for, but since then I've done very little, opting to usually store data in SQL as opposed to CSV...

Yesterday I wrote a CSV class and after toying with it today I had some cool ideas which I could implement to really extend a normal CSV class...

Basically add functionality to so it executed much like an Excel spreadsheet or SQL table...using a hybrid of SQL...

I could personally use the class...as I often write applications which run without SQL, but could use a limited bit of it's functionality...

So I ask, does anyone else ever find the need to work with CSV and more importantly...work with it programmatically, not just indirectly through dumping email addy's from outlook, etc...?

Cheers :)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

give me said class! If I have to work with one more CSV sheet I will kill myself. Make my life easier! Please! Sorry, I'm excited. :-D
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

would've been nice for me to have about 4 months ago...

I'm sure the need will crop up again.

post it when you're done.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Charles256 wrote:give me said class! If I have to work with one more CSV sheet I will kill myself. Make my life easier! Please! Sorry, I'm excited. :-D
It's no where near what I have said would be ideal (for my own interests) currently it's just a simple API...

looks like:

Code: Select all

function CxCSV($delim = ',', $arr_colnames=null)    

function csvLoad($file_name) /* public */
function csvSave($file_name) /* public */

function csvAppend($args)	/* public	*/
function csvUpdate($args)	/* public	*/
function csvDelete($args)	/* public	*/

function csvFields(){ return $this->m_arrColNames; }
function csvList($args, $sort_order = true, $start, $offset) /* public */

function _setEntry($args, $idx=-1)	/* protected */
function _findIndex($args)	/* protected */
function _compareArgsToColNames($args)	/* protected */
However after some thought I think I'm going to change the API quite drastically:

Code: Select all

// $arr_colnames is used if the first line in CSV file isn't field names
// this way programmer can explicitly define them in ctor()

function CxCSV($delim = ',', $arr_colnames=null)    

function csvLoad($file_name) /* public */
function csvSave($file_name) /* public */
function csvMerge($arr_files) /* public */

// Locate the index of a given record based on field comparison criteria
function findIndex(&$args)	/* public */

function appendRow($args) /* public */
function insertRow($idx, $args) /* public */
function updateRow($idx, $args) /* public */
function deleteRow($idx, $args) /* public */
function swapRow($idx1, $idx2) /* public */

// Return array with names of columns
function getColNames() /* public */

function listRows($args, $filter=null, $cb_func=null) /* public */
Or something to that effect :P

Comments, suggestions, etc...?

Cheers :)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Charles256 wrote:give me said class! If I have to work with one more CSV sheet I will kill myself. Make my life easier! Please! Sorry, I'm excited. :-D
viewtopic.php?t=47855

Take a looksie and gimme feedback :)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

i'll test when i get back home
Post Reply