I have a CSV file in which these are the following fields. Therefore, I only reduce the required field here.
"id.attr.id", "id.attr.id1", "id.attr.id2", "id.attr.id7", "Id.attr.arry", "Id.attr.arry1", "id.attr.arry2", "id.attr.arry5", "id.attr.arry4" "0", "8",, "8", "0" "3 "7", "7", "7", "3" "4",, "8", "8", "4" 5 "," 7 "," 5 "," 7 " "5" "4", "8", "4", "8", "3", "7",, "7", "3"
Now to define the problem, therefore, for the "id.attr.id" group which means ("id.attr.id", "id.attr.id1", "id.attr. Id2 "," id.attr.id7 ")
& amp; "id.attr.arry"
group means ("id.attr.arry", "id.attr.arry1", "id.attr.arry2", "Id.attr .arry5 "," id.attr.arry4 ")
I need to return all the multi-field values.
So what I have done is that.
OpenCSS (string filename) {{BufferedReader bufferedReader = new BufferedReader (new FileReader (filename)) to use header for private zeros parsing mesh; String line; Stringbuilder builder = new stringbiller (); Int count = 0; Boolean process header = wrong; Maps & lt; Integer, string & gt; ColumnIndexMap = New Hashmap & lt; Integer, string & gt; (); While ((line = bufferedReader.readLine ()) = null) {// We only process the header line and prepare the column index map, if (processor header) {processHeader = true; CSVR Reader = New CSVRder (new stringreader (line)); String [] line = reader Reed (); (Int i = 0; i & lt; row.length; i ++) for {string column name = row [i]; If (columnName.matches ("id.attr.id (. *)")) {ColumnIndexMap.put (i, columnName); }}} {// Here we process al data lines and maintain a buffer count; Builder.append (line) .append ("\ n"); If (count% 500 == 0) {process (builder.toString (), columnInndexMap); Builder = new stringbiller (); }}} If (builder .length ()> gt; 0} {process (builder.string ()), column index map; }} Hold (FileNotFoundException e) {System.err.println (e.getMessage ()); } Hold (IOException e) {System.err.println (e.getMessage ()); }} Private zero process throws IOException (string record, map and lieutenant; integer, string & gt; column index map) {CSV reader reader = new CSVRDER (new string reader (record)); Maps & lt; String, string & gt; ColumnValueMap; (String [] for line: reader.readAll ()) {columnValueMap = new hashmap & lt; String, string & gt; (); {If (columnIndexMap.containsKey (i)) {string value = line [i]; (for int i = 0; i & lt; row.length; i ++); If (value.trim (). Length ()> gt; {columnValueMap.put (columnIndexMap.get (i), value);}}} // if (columnValueMap> i) {System.out.println (" ColumnValueMap = "+ columnValueMap);}}}}
Then this program is returning all the values in the" id.attr.id "group. Now the column validity returns what all the maps The value of the column is as follows.
As expected results are:
The program should return from the given CSV.
4 , 8,5,7,51 4,8 3,7
Also, please do let me know with the "id.attr You can provide potential changes in tan .id "group" id.attr.arry "matches the group, if so, we also need to return them too.
0 3 4 , 8 5,7 4,8 3,7,
No comments:
Post a Comment