Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package jrex;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.Reader;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.commons.csv.CSVFormat;
- import org.apache.commons.csv.CSVParser;
- import org.apache.commons.csv.CSVRecord;
- /**
- *
- * @author jonat
- */
- public class company_link_csv_reader {
- private static final String SAMPLE_CSV_FILE = "./sample.csv";
- public static List<String> main() throws IOException ,FileNotFoundException{
- try (
- Reader reader = Files.newBufferedReader(Paths.get(SAMPLE_CSV_FILE));
- CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT);
- ) {
- List<CSVRecord> csvRecords = csvParser.getRecords();
- List<String> company_ink_list = new ArrayList<String>();
- int x = 0;
- while(x < csvRecords.size()){
- //Get the company page
- CSVRecord recordlist = csvRecords.get(x);
- String[] print = recordlist.toString().split(",");
- //int ll = print[3].length();
- String linkstrings = print[3].replace("values=[", "").replace("]", "").replace(" ","").replace("https://", "").replace("http://", "");
- company_ink_list.add(linkstrings);
- x++;
- }
- //System.out.println(csvRecords);
- return company_ink_list;
- } }
- }
Advertisement
Add Comment
Please, Sign In to add comment