本文整理汇总了Java中org.apache.commons.csv.CSVRecord.size方法的典型用法代码示例。如果您正苦于以下问题:Java CSVRecord.size方法的具体用法?Java CSVRecord.size怎么用?Java CSVRecord.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.csv.CSVRecord
的用法示例。
在下文中一共展示了CSVRecord.size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUniqueFields
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
private static String[] getUniqueFields(File inFile) throws IOException {
CSVParser parser = new CSVParser(new BufferedReader(new FileReader(inFile)),
CSVFormat.EXCEL.withNullString(NULL_STRING));
// first record used as header
CSVRecord header = parser.iterator().next();
List<String> uniqueFields = new ArrayList<String>();
for(int i = 0; i < header.size(); i++) {
String col = header.get(i);
if (!uniqueFields.contains(col)) {
// we can add it directly
uniqueFields.add(col);
} else {
// disambiguate by appending index
uniqueFields.add(col + "_" + i);
}
}
return uniqueFields.toArray(new String[0]);
}
示例2: createTagPool
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
private List<TagPool> createTagPool(CSVParser parser) throws BuenOjoCSVParserException{
ArrayList<TagPool> list = new ArrayList<>();
for (CSVRecord record : parser) {
String name = record.get(TagPoolColumn.TAG.ordinal()).toString();
Tag tag = tagMap.get(name);
for (int i = TagPoolColumn.SIMILAR_1.ordinal(); (i <record.size()) && i <= TagPoolColumn.SIMILAR_3.ordinal(); i++) {
String similarTagName = record.get(i);
if (similarTagName != null && !StringUtils.isAnyEmpty(similarTagName)){
Tag similarTag = tagMap.get(similarTagName);
if (similarTag != null){
TagPool tagPool = new TagPool();
tagPool.setTag(tag);
tagPool.setSimilarTag(similarTag);
tagPool.setSimilarity(i);
list.add(tagPool);
} else {
throw new BuenOjoCSVParserException("no se pudo obtener la etiqueta con nombre: '"+similarTagName+"'");
}
}
}
}
return list;
}
示例3: load
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
public static void load(File location, AbstractDataModel sAbstractData) {
CSVHParser parser = FileUtils.getCSVHParser(location);
if (parser != null) {
for (CSVRecord crecord : parser.getRecords()) {
List record = sAbstractData.getNewRecord();
for (int i = 0; i < crecord.size(); i++) {
record.add(crecord.get(i));
}
sAbstractData.addRecord(record);
}
}
}
示例4: loadFileinTable
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
public static void loadFileinTable(File file, JTable table) {
if (file.exists()) {
try (Reader in = new FileReader(file)) {
CSVParser parser = CSVFormat.EXCEL.withHeader().withSkipHeaderRecord().withIgnoreEmptyLines().parse(in);
if (!parser.getHeaderMap().isEmpty()) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
for (String columnHeader : parser.getHeaderMap().keySet()) {
if (!columnHeader.trim().isEmpty()) {
model.addColumn(columnHeader);
}
}
List<CSVRecord> records = parser.getRecords();
for (CSVRecord record : records) {
Object[] row = new Object[record.size()];
for (int i = 0; i < record.size(); i++) {
row[i] = record.get(i);
}
model.addRow(row);
}
}
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
} else {
LOGGER.log(Level.SEVERE, "File [{0}] doesn''t exist", file.getAbsolutePath());
}
}
示例5: loadStep
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
private void loadStep(CSVRecord record) {
for (int i = 0; i < record.size(); i++) {
stepDetails.add(record.get(i));
}
while (stepDetails.size() != HEADERS.values().length) {
stepDetails.add("");
}
}
示例6: loadStep
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
private void loadStep(CSVRecord record) {
for (int i = 0; i < record.size(); i++) {
exeStepDetails.add(record.get(i));
}
}
示例7: getString
import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
public static String getString(CSVRecord record, int index) {
return index < record.size() ? StringUtils.trim(record.get(index)) : null;
}