How can I access data in a CSV file, like I want data from from a certain cell and store it in a variable, but without using SQL. Any references would be also great to read about it
            Asked
            
        
        
            Active
            
        
            Viewed 453 times
        
    -1
            
            
        - 
                    2take a look at http://stackoverflow.com/questions/101100/csv-api-for-java – yegor256 Feb 05 '13 at 09:19
- 
                    I'm confused: Why do you think you need a SQL engine to access a CSV file? – Feb 05 '13 at 10:09
2 Answers
1
            
            
        import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import au.com.bytecode.opencsv.CSVReader;
public class CsvFileReader {
    public static void main(String[] args) {
        try {
            System.out.println("\n**** readLineByLineExample ****");
            String csvFilename = "C:/Users/hussain.a/Desktop/temp/20130128.csv";
            CSVReader csvReader = new CSVReader(new FileReader(csvFilename));
            String[] col = null;
            while ((col = csvReader.readNext()) != null) {
                System.out.println(col[0] + " # " + col[1]);
                //System.out.println(col[0]);
            }
            csvReader.close();
        } catch (FileNotFoundException e) 
        {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
you can attach the jar from here
 
    
    
        Hussain Akhtar Wahid 'Ghouri'
        
- 6,527
- 8
- 50
- 85
0
            
            
        You need to open the CSV file, run it through a CSV parser, and use the API on the parser to extract whatever information you need.
 
    
    
        NickJ
        
- 9,380
- 9
- 51
- 74
 
    