s4int / robotframework-csvlibrary Goto Github PK
View Code? Open in Web Editor NEWRobot Framework keyword library for CSV files
License: Apache License 2.0
Robot Framework keyword library for CSV files
License: Apache License 2.0
When reading a CSV file into RF, the Library implicitly converts INTs to FLOATs.
Example CSV data:
1,"Some","Data"
2,"More","Stuff"
RF:
Example test
${csv_data}= Read Csv File To List ${CSV File} quoting=${2}
Result:
[info] ${csv_data} = [[1.0, 'Some', 'Data'], [2.0, 'More', 'Stuff']]
Currently when using CSVLibrary to load CSV files into a list of dictionaries, it is loading them as the standard python library as OrderedDict's.
To make the result usable as other Dictionaries created by Robot Framework, it would be nice to use the Robot Framework sub classed DotDict class instead. ( robot.utils.dotdict.DotDict )
With the DotDict class it would be possible to do like this (as long as the header does not contain spaces):
*** Test Cases ***
Read csv file to a dict example test
@{dict}= read csv file to associative data.csv
Log ${dict[0].first_name} ${dict[0].last_name}
The error handler for _csv.writer tries to use the same logging as _csv.reader. CSV readers have a line_num attribute but CSV writers do not.
In different languages it might be needed to store external data in other encodings than the OS default.
So it would be very convenient to be able to set the encoding while loading and saving CSV files.
Python 3 built in function "open" has the parameters already, so the parameters "just" has to be fed through to the call.
For Python 2, it far more complicated, the io.open is more or less the same as in Python 3, but the csv library in Python 2 does not support unicode at all. So if Python 2 is needed, the file would have to be opened in binary mode and processed or decoded while reading. There exists a replacement csv library for python 2 solving this though. (https://github.com/jdunck/python-unicodecsv)
When trying to install csvlibrary with python3 getting below error. It seems it is yet support python3.
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/fr/jtjjqpbs1sx0lxh6qbgzgdjw00gftq/T/pip-build-nyn_ua1n/robotframework-csvlibrary/
Kindly provide the support for python3 as well.
Empty Csv File ${outputFile}
@{list}= Read Csv File To List ${inputFile}
@{list}= Change dateField for the csv data ${list} ${stlDate} ${dataSource}
Append To Csv File ${outputFile} ${list}
${inputFile} --> It is a CSV file containing the data
${outputFile} --> Created a empty csv file
The above code was working file with Python 2.7 and RF 3.1.2 with the version 0.0.3
But after upgrading the Python to 3.8, started getting the error ""IndexError: list index out of range"
for the keyword Append To Csv File
Please help on this.
Please add a possibility to "read csv file to associative" from variable.
Currently the only option is to read from a csv file.
It would be nice to load it from a variable too.
Please put a universal, Py2 & Py3, build of this on PyPi. https://pypi.org/project/robotframework-csvlibrary/ is still at version 0.0.2
Please add CSV write example
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.