Coder Social home page Coder Social logo

ofxcsv's Introduction

ofxCsv

ofxCsv is an addon for openFrameworks to read and write CSV(Character Separated Values) files.

You can choose a character separator to create individual tables.

Inspired and based on Ben Fry's table class.

Check out for new release at https://github.com/paulvollmer/ofxCsv

Current Version

0.2.1 (stable and versioned using semantic versioning)

Basic API Overview

ofxCsv:

load(string path, string separator, string comment)
load(string path, string separator)
load(string path)

load(vector<ofxCsvRow> rows)
load(vector<string> rows)

save(string path, bool quote, string separator)
save(string path, bool quote)
save(string path)

createFile(string path)

addRow(ofxCsvRow row)
addRow()
setRow(int index, ofxCsvRow row)
getRow(int index)
insertRow(int index, ofxCsvRow row)
removeRow(int index)

ofxCsvRow:

load(string cols, string separator)
load(vector<string> cols)

getInt(int col)
getFloat(int col)
getString(int col)
getBool(int col)

addInt(int what)
addFloat(int what)
addString(int what)
addBool(int what)

setInt(int col, int what)
setFloat(int col, float what)
setString(int col, string what)
setBool(int col, bool what)

insertInt(int col, int what)
insertFloat(int col, float what)
insertString(int col, string what)
insertBool(int col, bool what)

remove(int col)

See src/ofxCsv.h & src/ofxCsv.h for detailed information & additional functionality.

Installation & Usage

To install ofxCsv, move the ofxCsv folder to your openFrameworks/addons folder.

Basic usage is demonstrated by csvExample.

With OF version 0.9.0+, the OF Project Generator will add the compiler search paths for the project automatically if configured to include ofxCsv.

Project files for the example are not included so you will need to generate the project files for your operating system and development environment using the OF ProjectGenerator which is included with the OpenFrameworks distribution.

Press the Import button in the ProjectGenerator & select the addons/ofxCsv/csvExample folder. Next, press the "Generate" to populate the example with the project files you will need to build it on your OS.

Issues and Bugs

You can find a list of all known bugs at GitHub. Please report if you find an unknown bug.

Changelog

A detailed changelog, intended for programmers.

0.2.1
bugfix for OF 0.10

0.2.0
partial rewrite & update to OF 0.9+, added ofxCsvRow

0.1.3
small bugfix (thanks to Pinkerton)

0.1.2
moved to ofxCsv Repository

0.1.1b
small changes (also at ofxWrongPowder Repository)

0.1.0
starting addon at ofxWrongPowder Repository

Contributors

License

ofxCsv is Licensed under MIT Public License: http://www.opensource.org/licenses/MIT

See also, LICENSE in this distribution.

ofxcsv's People

Contributors

bitdeli-chef avatar carthach avatar danomatika avatar ofcinzio avatar paulvollmer avatar schwittlick avatar tado avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ofxcsv's Issues

Feature Request: numRows()

It would be really nice if we could load the csv file and get the number of rows for easy processing in loop.

Alternatively a iterators solution may work better for easy looping over the csv.

table draw funcion

a function for displaying the csv file.
or need a drawing function an other addon?

how to combine the addon with ofxCrypto when loading file?

I would like to read an encrypted csv file using this addon:
https://github.com/jkosoy/ofxCrypto
My idea is to hide the file (previously encrypted outside OF) when using my app on an installation.
ofxCrypto encodes strings (md5 or sha1) and buffers using base64.

Now I am reading a plain csv file with ofxCsv and I would like to know how to start to try to do this:
I want to combine both plugins, and to modify ofxCsv to read the csv encrypted file, decode and read the rows/columns.
but I don't know how to manage ofBuffers and ofFile yet...
any help is appreciated.

Compiling on Ubuntu - regex_replace error

I am trying to use this addon on Ubuntu, with OF 0.9.8. I have the following error:

/home/nuc/Documents/Code/openFrameworks/addons/ofxCsv/src/ofxCsvRow.cpp: In member function ‘void ofxCsvRow::trim()’:
/home/nuc/Documents/Code/openFrameworks/addons/ofxCsv/src/ofxCsvRow.cpp:315:50: error: no matching function for call to ‘regex_replace(std::string&, std::regex&, const char [3])’
   col = std::regex_replace(col, s_trimRegex, "$1");

Any idea how to fix this?

Openframeworks 0.10 compile Errors

Seems to be compiling issues with 0.10 latest version. withing the file ofxCsvRow.h

'string'; did you mean 'std::string'
'vector'; did you mean 'std::vector'

how to hardcode an external .csv file to ofxCsv object

hey @paulvollmer , thanks for your addon, it's being very helpful!

I am using it to make a time playlist event trigger. I am loading an external file using a space " " as separator and it's working really fine.

Now, after having the file finished, I want to hardcode all the file into the OF ofApp, just to hide the file for unwanted modifications.

my file.csv looks like:

TIME DEV_TYPE ID COMMAND FADE_TIME
2000 RELAY 3 ON
2500 DMX 4 FADE_IN_PAUSE_OUT 2000
3000 RELAY 4 ON
3400 RELAY 8 ON

I am tring to joint all the lines into a string or a vector of string and then to try to use your load function to load the string... but I am not having success! :)

My idea is to not have to use all the addRow, addString methods manually, and just copy paste all lines from the external text editor to OF with something like that:
string myCSVfullString = "TIME DEV_TYPE ID COMMAND FADE_TIME\n2000 RELAY 3 ON\n ...";

I am trying with your

load(vector<string> rows)

method with a push_back for any line too, also trying with commas besides spaces, but without success neither...

any help? or that has not sense for you?
Thanks

sorting by column

Thank you for this great addon. It's super useful.
Is there a way to sort according to a specific column?
I assume not since I did not see any in the code. But maybe you know of a good reference that I can use to implement it.

I will look around myself too.

Thank you.

Raspbian compilation error: 'string' does not name a type

Hello,

I'm having trouble compiling on Raspbian (on an RPi 3). I followed the openFrameworks installation guide at https://forum.openframeworks.cc/t/compiling-of-in-raspbian-stretch/27562/15 (using their method 1) successfully, but when I try and make ofxCsv (through a make of a project called Footfall (https://github.com/WatershedArts/Footfall) which names ofxCsv as a dependency) the make fails with the following message:

...
In file included from /home/pi/openFrameworks/addons/ofxCsv/src/ofxCsv.h:33:0,
                          from /home/pi/openFrameworks/addons/ofxCsv/src/ofxCsv.cpp:31:
/home/pi/openFrameworks/addons/ofxCsv/src/ofxCsvRow.h:45:19: error: 'string' does not name a type
  ofxCsvRow(const string &cols, const string &separator=",");
/home/pi/openFrameworks/addons/ofxCsv/src/ofxCsvRow.h:45:39: error: 'string' does not name a type
  ofxCsvRow(const string &cols, const string &separator=",");
/home/pi/openFrameworks/addons/ofxCsv/src/ofxCsvRow.h:48:19: error: 'vector' does not name a type
  ofxCsvRow(const vector<string> &cols);
...
...
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:358: recipe for target '/home/pi/openFrameworks/addons/obj/linuxarmv6l/Release/ofxCsv/src/ofxCsvRow.o' failed
make[1]: *** [/home/pi/openFrameworks/addons/obj/linuxarmv6l/Release/ofxCsv/src/ofxCsvRow.o] Error 1
make[1]: Leaving directory '/home/pi/openFrameworks/apps/Footfall/Footfall'
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:124: recipe for target 'Release' failed
make: *** [Release] Error 2

I'm using oF version 0.9.8 and gcc 6.3 on Linux raspberrypi 4.9.80-v7+ #1098 SMP Fri Mar 9 19:11:42 GMT 2018 armv7l GNU/Linux.

Any help or information you can give is greatly appreciated.

Thanks!

Error loading first value of first row

I always seem to get 0 when I load the first value of the first row. For example for the following csv file:

20,3,2 2,34,12 293,12,1 39,10,10
using this code:
`
ofxCsv thisCsv;
ofSetLogLevel(OF_LOG_VERBOSE);

if (thisCsv.load("test.csv"))
{
	ofLog(OF_LOG_VERBOSE) << "there should not be an 0's below";
	for (int i = 0; i < thisCsv.size(); i++)
	{
		ofxCsvRow thisRow = thisCsv.getRow(i);
		
		int val1 = thisRow.getInt(0);
		int val2 = thisRow.getInt(1);
		int val3 = thisRow.getInt(2);

		ofLog(OF_LOG_VERBOSE) << val1 << "," << val2 << "," << val3;
	}
}`

I always get 0 for val1? This is of9.8 windows, 0.20 of the addon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.