How do you convert a CSV file into a 2D array in Java or C++ -


my question title didn't outline question. have text file has many lines of data each line in following format:

 a, date, b, c, d, username, e, description 

a,b,c,d, , e not need used anything.

notes:

  • the dates in format -> 2013-04-07t22:23:58z (the "t22:23:58z" not needed)
  • descriptions either login, logout, or extend
  • same usernames show multiple times throughout file

i need write code take data text file, , output users extended day , how many times.

example of text file:

 a,2013-04-07t22:23:58z,b,c,d,john,extend a,2013-04-07t22:23:51z,b,c,d,john,login a,2013-07-07t22:23:51z,b,c,d,john,extend a,2013-04-07t22:23:58z,b,c,d,mark,extend a,2013-03-07t22:23:51z,b,c,d,frank,login a,2013-07-11t22:23:51z,b,c,d,john,extend 

example output:

 2013-04-07: john -> 1 extend mark -> 1 extend  2013-07-07: john -> 1 extend  2013-07-11: john -> 1 extend 

can explain me, or better yet show me how can this?

not required language, here solution in awk :)

#!/bin/awk begin {   fs=","; } /extend/{     split($2,date,"t");     dates[date[1],$6]++; } end {   last = ""   n = asorti(dates, dest)   (i = 1; <= n; i++) {     split(dest[i], idx, subsep)     if ( last != idx[1]) {       last = idx[1]       print "\n"idx[1]     }     print idx[2] " -> " dates[idx[1], idx[2]] " extend"   } } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -