CSV Library

677 views
Skip to first unread message

Jakub Dziekan

unread,
Mar 29, 2013, 5:37:39 AM3/29/13
to robotframe...@googlegroups.com
Hello, my name is Jacob and i'am a begining RF developer.
Now i'am creating CSV Library in python.

And i have some of questions to yours.
What method (functions) you need and which you will be need in future :)
I don't have ideas for more methods and please say me what you will be need:)

now i have:

csvLibrary.Get Actual Row Number
csvLibrary.Get Count Cell In Row
csvLibrary.Get Count Rows
csvLibrary.Get Next Row
csvLibrary.Get Previous Row
csvLibrary.Get Row By Number
csvLibrary.Open Csv


p.s. Sorry for my hurt english :)

Guy Kisel

unread,
Mar 29, 2013, 5:43:38 PM3/29/13
to robotframe...@googlegroups.com
I'm not sure if you're aware of this already, but Python has a built in csv library - http://docs.python.org/2/library/csv.html 

This should make it pretty easy to write a RF csv library :)

David

unread,
Mar 30, 2013, 2:07:29 AM3/30/13
to robotframe...@googlegroups.com
Good discussion. Whether you can create your own CSV library easily or not, for non-developer RF users, and to save time & effort for others, it would be nice to have a prebuilt CSV library for use, perhaps built out of the Python CSV library mentioend by Guy.

Jakub, it's not clear what some of your current keywords do based on the name (perhaps not clear English). Here's some thoughts on improving the library with additional keywords/features:

* close CSV file?
* CSV write methods? to write a row or rows, or replace/overwrite a row or rows...
* library startup option or keyword to set CSV delimiter (comma, tab, space, etc. defaults to comma)
* library startup option to specify whether CSV file has header fields (default to no, if yes treat first row as header fields and 2nd row as first data row)
* or maybe in addition to library startup options above, those options could be specified in keyword that opens CSV file as well (as optional arguments with default values)
* get current cell/column number?
* get number of columns (in row)?
* get CSV header fields (as row/dictionary, always first row) - return null or empty list if library setting/parameter for CSV header is "no"
* get_cell_by_row_and_column_number(row_number,column_number)
* get_cell_by_row_number_and_column_name(row_number,column_name) 'column name = from CSV header field name
* get_cell_in_current_row_by_number(column_number)
* get_cell_in_current_row_by_column_name(column_name)
* go to first row (~rewind)
* go to last row?
* a keyword to return CSV data as 2d array (assuming can fit into memory, so that user can then manipulate as they see fit as Python object)

and when you get/return a row, what is the data type returned? List, tuple, dictionary? I forget the exact data types supported by Robot Framework, but it would be nice if you have the option to return a row in 2 formats:

cells mapped by index/column number {0: cell1value, 1: cell2value}

cells mapped by field name (in cases where CSV has header fields) {fieldname1: value, fieldname2: value} 

Jakub Dziekan

unread,
Apr 2, 2013, 3:43:09 AM4/2/13
to robotframe...@googlegroups.com
I know and i using csv library :)
But csvLib in RF is dedicated for normal(non python developers) users.

David

unread,
Apr 2, 2013, 12:56:45 PM4/2/13
to robotframe...@googlegroups.com
Just to add to the discussion, I wonder how many (normal) users work with CSV in the most primitive way (access cells or columns by index) vs the more intuitive/user-friendly way (access cells/columns by name, if the CSV contained header names).

Granted, in general, the latter option only works, from a programming standpoint, if the user knew how to extract out the header names and map the name to index so that you can reference cells by row # column name rather than row # column #. Though if a CSV library was well written, the user wouldn't have to figure that out. They just need to know the column name they will be using and it will just work nicely.

I personally prefer accessing by column names so that if the columns ever get reordered or you add/remove columns, you don't have to worry about updating index # since the names will automatically map back to the index # appropriately if mapped correctly. You just have to make sure the header names don't get renamed often. It's also then more intuitive in the test/code what data is being accessed when not using column index.
Reply all
Reply to author
Forward
0 new messages