Menu

Reading a CSV file into memory for collecting statistics

Help
shlomo
2015-03-05
2015-03-07
  • shlomo

    shlomo - 2015-03-05

    Hi,
    I am interested in reading a CSV having the following format:
    key,value
    xxx,0
    yyy,1
    uuu,0
    zzz,4
    ddd,4
    etc etc

    Subsequently I am interested in finding out the frequency of occurrences of "value".
    For instance WRT the table above, 4 appears twice so this will result in:
    4-->2
    0-->2
    1-->1

    Later I want to draw a histogram of occurrences (maybe with OpenCV?), this comes easily with MATLAB or R which can plot a histogram (with bins).

    I am thinking about using boost bi-map, like so:
    http://mybyteofcode.blogspot.com/2010/02/parse-csv-file-with-boost-tokenizer-in.html

    Is there a better alternative using dlib? would I have any issues if I use boost data structures and later read these into dlib matrix?

    Thanks,

     
    • Davis

      Davis - 2015-03-05

      You can mix and match things from many libraries without issue. So no
      worries.

       
  • shlomo

    shlomo - 2015-03-07

    The latest version of boost and the latest version of dlib don't play together well.
    See my post here:
    http://forum.openframeworks.cc/t/using-boost-dlib-ofxlearn-and-of-on-osx-10-10/18799

     
    • Davis

      Davis - 2015-03-07

      Dlib is just a folder of C++ source files. You can use it together with
      any other library. In particular, I use boost and dlib together frequently
      and there are no issues.

      In the link you posted, it sounds like you are having a rough time getting
      boost working, which has nothing to do with dlib.

       
  • shlomo

    shlomo - 2015-03-07

    Hi,
    Thank you for your reply.

    Boost is working perfectly as long as dlib is not involved.
    I can even integrate dlib with boost (and this is the catch) as long as i dont include these header files:

    include <dlib image_processing="" frontal_face_detector.h="">

    include <dlib image_processing="" render_face_detections.h="">

    include <dlib image_processing.h="">

    include <dlib gui_widgets.h="">

    include <dlib image_io.h="">

    See the screenshoots, the error is from dlib not boost:

     
  • shlomo

    shlomo - 2015-03-07

    second pic

     
  • shlomo

    shlomo - 2015-03-07

    working when the headers are not included

     
    • Davis

      Davis - 2015-03-07

      Maybe someone has created a #define called verify? Also, do not #include
      cpp files, especially in headers. If you are doing that then many things
      will break.

      In any event, this isn't a bug in dlib. Also, you keep asking me about
      very basic programming questions that are not dlib specific. So the best
      advice I can give you is to get a good programming book and read it. I
      have a list of suggestions here: http://dlib.net/books.html

       
  • shlomo

    shlomo - 2015-03-07

    "Also, do not #include cpp files, especially in headers." this was your suggestion in one of the previous posts ... I was surprised that you suggested it!. and if you noticed, that line was commented out.

    "very basic programming questions ..."? at least you made me smile ... I have 15 years of programming experience mainly in java but still ...
    The fact that i asked if I can mix boost and dlib? this was only because it didn't compile and there are several other posts in this forum about this issue, for instance this one which deals with namespace collisions: https://sourceforge.net/p/dclib/discussion/442517/thread/cfd6538b/

    You are welcomed to upload a working Xcode project with the latest dlib and latest boost where the aforementioned header are included, I will probably move to using another library.

     
    • Davis

      Davis - 2015-03-07

      No, I never told you to #include cpp files.

      Those namespace collisions have been removed. And in any event, your
      questions really are general questions about using C++ and xcode rather
      than about dlib or even boost. So it really would be a good idea to get a
      C++ book if you want to keep writing C++ code.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.