{"id":6434,"date":"2014-02-23T05:08:13","date_gmt":"2014-02-22T18:08:13","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=6434"},"modified":"2014-02-23T05:08:13","modified_gmt":"2014-02-22T18:08:13","slug":"java-csv-file-read-and-process-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/java-csv-file-read-and-process-primer-tutorial\/","title":{"rendered":"Java CSV File Read and Process Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Java\/CSVFileRead\/FileArrayList.jpg\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Java CSV File Read and Process Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Java\/CSVFileRead\/FileArrayList.jpg\" title=\"Java CSV File Read and Process Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Java CSV File Read and Process Primer Tutorial<\/p><\/div>\n<p>Here is a tutorial that reads an input CSV file which is entirely numeric and uses ArrayList structures in Java on a Mac laptop to store the data of the file.<\/p>\n<p>It is generic in the sense that integer or double data is allowed (the pattern is established by examining the first valid record) and delimiters of comma or space are allowed.   Although the <i>C<\/i> in CSV stands for <i>Comma<\/i> (Separated Values) it is often the case that two files are functionally equivalent CSV files as far as behaviours go just by a redefinition of the delimiter, and often people use a space character as that delimiter.<\/p>\n<p>CSV files have been a prominent form of data transmission ever since the early days of the PC&#8217;s first <i>&#8220;killer app&#8221;<\/i>, the <a target=_blank title='Spreadsheet information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Spreadsheet'>spreadsheet<\/a>.   Without the spreadsheet in those early days, personal computing may not have taken off to the degree it has arrived at today.<\/p>\n<p>As long as the first record is typical of the rest it should successfully fill an appropriate ArrayList with numerical file data.<\/p>\n<p>The input file is asked using <a target=_blank title='java.util.Scanner' href='http:\/\/docs.oracle.com\/javase\/1.5.0\/docs\/api\/java\/util\/Scanner.html'>java.util.Scanner<\/a> methods and the file is read using <a target=_blank title='java.io.BufferedReader' href='http:\/\/docs.oracle.com\/javase\/6\/docs\/api\/java\/io\/BufferedReader.html'>java.io.BufferedReader<\/a> methods.<\/p>\n<p>This <a target=_blank title='java.io.BufferedReader advice' href='http:\/\/www.mkyong.com\/java\/how-to-read-file-from-java-bufferedreader-example\/'>link<\/a> was very helpful regarding the reading of text files using Java, so, thanks.<\/p>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/Java\/CSVFileRead\/FileArrayList.jpg'>Java<\/a> programming code for this, and how it works in practice.\n<\/p>\n<p>Download source code and rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/Java\/CSVFileRead\/FileArrayList.java_GETME'>FileArrayList.java<\/a><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d6434' onclick='var dv=document.getElementById(\"d6434\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=ArrayList\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d6434' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a tutorial that reads an input CSV file which is entirely numeric and uses ArrayList structures in Java on a Mac laptop to store the data of the file. It is generic in the sense that integer or &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/java-csv-file-read-and-process-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[104,283,644,997,1319],"class_list":["post-6434","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-arraylist","tag-csv","tag-java","tag-programming","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/6434"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=6434"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/6434\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=6434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=6434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=6434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}