au.com.bytecode.opencsv.CSVReader.readAll()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中au.com.bytecode.opencsv.CSVReader.readAll()方法的一些代码示例,展示了CSVReader.readAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CSVReader.readAll()方法的具体详情如下:
包路径:au.com.bytecode.opencsv.CSVReader
类名称:CSVReader
方法名:readAll

CSVReader.readAll介绍

[英]Reads the entire file into a List with each element being a String[] of tokens.
[中]将整个文件读入一个列表,每个元素都是一个令牌字符串[]。

代码示例

代码示例来源:origin: databricks/learning-spark

public Iterable<String[]> call(Tuple2<String, String> file) throws Exception {
  CSVReader reader = new CSVReader(new StringReader(file._2()));
  return reader.readAll();
 }
}

代码示例来源:origin: stackoverflow.com

// Read all
CSVReader csvReader = new CSVReader(new FileReader(new File("nrldata.txt")));
List<String[]> list = csvReader.readAll();

// Convert to 2D array
String[][] dataArr = new String[list.size()][];
dataArr = list.toArray(dataArr);

代码示例来源:origin: net.serenity-bdd/serenity-core

protected List<String[]> getCSVDataFrom(final Reader testDataReader) throws IOException {
  List<String[]> rows;
  try (CSVReader reader = new CSVReader(testDataReader, separator, quotechar, escape, skipLines)) {
    rows = reader.readAll();
  }
  return rows;
}

代码示例来源:origin: stackoverflow.com

CSVReader reader1 = new CSVReader(new FileReader(mydata_csv.getpath()));
List<String[]> myDatas = reader1.readAll();
String[] lineI = myDatas.get(i);
for (String[] line : myDatas) {
  for (String value : line) {
    //do stuff with value
  }
}

代码示例来源:origin: stackoverflow.com

try {
  CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(new File("/path/to/your/file.csv"))));
  Map<String, String> result = new HashMap<String, String>();
  for(String[] row : reader.readAll()) {
    result.put(row[0], row[1]);
  }
} catch (FileNotFoundException e1) {
  e1.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}

代码示例来源:origin: stackoverflow.com

CSVReader reader = new CSVReader(new FileReader(fName), ',','"','|');
 List content = reader.readAll();//do not use this if CSV file is large
 String[] row = null;
 for (Object object : content) {
   row = (String[]) object;
   row = Arrays.toString(row).split(",");
   //now you have a row array with length equal to number of columns
 }

代码示例来源:origin: stackoverflow.com

try (CSVReader reader = new CSVReader(new BufferedReader(
     new FileReader(pathToCSVFile)));) {

  List<String[]> lines = reader.readAll();
  return lines.toArray(new String[lines.size()][]);
}

代码示例来源:origin: movsim/movsim

public static List<String[]> readData(File file, char separator) {
  LOG.info("using input file={}", file.getAbsolutePath());
  List<String[]> myEntries = Lists.newArrayList();
  // see http://opencsv.sourceforge.net/#how-to-read
  try (CSVReader reader = new CSVReader(new FileReader(file), separator)) {
    myEntries = reader.readAll();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return myEntries;
}

代码示例来源:origin: stackoverflow.com

CSVReader reader = new CSVReader(new FileReader(
       "myfile.csv"));
   try {
     List<String[]> myEntries = reader.readAll();
     for (String[] s : myEntries) {
       for(String ss : s) {
         System.out.print(", " + ss);
       }
     }
   } catch (IOException e) {
     e.printStackTrace();
   }

代码示例来源:origin: stackoverflow.com

// should probably throw something more specific
private String[][] readCsv() throws Exception { 
  // Read all
  CSVReader csvReader = new CSVReader(new FileReader(new File(inFile)));
  List<String[]> list = csvReader.readAll();

  // Convert to 2D array
  String[][] dataArr = new String[list.size()][];
  dataArr = list.toArray(dataArr);

  return dataArr;
}

代码示例来源:origin: stackoverflow.com

String strSearch = searchSerialField.getText();
 CSVReader reader = new CSVReader(new FileReader("test.txt"), ',');
 List<String[]> myEntries = reader.readAll();
 reader.close();
 for (int row = 0; row<myEntries.size(); row++){
   for (int column = 0; column< myEntries.get(row).length; column++ ){
     if(myEntries.get(row)[column].trim().equalsIgnoreCase(strSearch)){
       System.out.println("found - your item is on row " +row + ", column "+ column);
     }              
   }
 }

代码示例来源:origin: stackoverflow.com

CSVReader reader = new CSVReader(new InputStreamReader(userManActionForm.getUploadFile().getInputStream()));
 List<String[]> entries = reader.readAll();
 List<Member> memberList = new ArrayList<Member>();
   for (String[] entry : entries) {
     Member member = new Member();
     member.setUserId(entry[USER_ID_INDEX]);
     member.setUserName(entry[USER_NAME_INDEX]);
     member.setGroup(entry[USER_GROUP_INDEX]);
     memberList.add(member);
   }

代码示例来源:origin: stackoverflow.com

public static List<String[]> read(String document) throws IOException{
   List<String[]> data = null;
   try{
     CSVReader reader = new CSVReader(new FileReader(document));
     data = reader.readAll();
     reader.close();
   } catch(IOException e){
     e.printStackTrace();
   }
   return data;
 }

代码示例来源:origin: stackoverflow.com

public static List<String[]> read(String document) throws IOException{
  List<String[]> data;
  try{
    CSVReader reader = new CSVReader(new FileReader(document));
    data = reader.readAll();
    reader.close();
  } catch(IOException e){
    e.printStackTrace();
  }
  return data;
}

代码示例来源:origin: stackoverflow.com

public static List<String[]> read(String document) throws IOException{
  List<String[]> data = null;

  try{
    CSVReader reader = new CSVReader(new FileReader(document));
    data = reader.readAll();
    reader.close();
  } catch(IOException e){
    e.printStackTrace();
  }

  return data;
}

代码示例来源:origin: stackoverflow.com

public class ExampleCSVWrite {
  public static void main (String[] args) throws IOException {
   CSVReader reader = new CSVReader(new  FileReader("/Users/aaronarpi/Documents/UA.csv"));
   List<String[]> myEntries = reader.readAll();
   reader.close();
  }
}

代码示例来源:origin: net.thucydides/thucydides-core

protected List<String[]> getCSVDataFrom(final Reader testDataReader) throws IOException {
  CSVReader reader = new CSVReader(testDataReader, separator);
  List<String[]> rows = Lists.newArrayList();
  try {
    rows = reader.readAll();
  } finally {
    reader.close();
  }
  return rows;
}

代码示例来源:origin: net.serenity-bdd/core

protected List<String[]> getCSVDataFrom(final Reader testDataReader) throws IOException {
  CSVReader reader = new CSVReader(testDataReader, separator, quotechar, escape, skipLines);
  List<String[]> rows = Lists.newArrayList();
  try {
    rows = reader.readAll();
  } finally {
    reader.close();
  }
  return rows;
}

代码示例来源:origin: sk89q/WarmRoast

public void read(File joinedFile, File methodsFile) throws IOException {
  try (FileReader r = new FileReader(methodsFile)) {
    try (CSVReader reader = new CSVReader(r)) {
      List<String[]> entries = reader.readAll();
      processMethodNames(entries);
    }
  }
  
  List<String> lines = FileUtils.readLines(joinedFile, "UTF-8");
  processClasses(lines);
  processMethods(lines);
}

代码示例来源:origin: org.seasar.dao-codegen/s2dao-codegen-core

public static List readCSVToArray(File srcFile, String encode) {
  BufferedReader bufferedreader = getBufferedReader(srcFile, encode);
  readLine(bufferedreader); // ヘッダ分読み飛ばし用
  CSVReader reader = new CSVReader(bufferedreader);
  try {
    return reader.readAll();
  } catch (IOException e) {
    throw new IORuntimeException(e);
  }
}

相关文章