• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CSVReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.googlecode.jcsv.reader.CSVReader的典型用法代码示例。如果您正苦于以下问题:Java CSVReader类的具体用法?Java CSVReader怎么用?Java CSVReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CSVReader类属于com.googlecode.jcsv.reader包,在下文中一共展示了CSVReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildCSVReader

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
/**
 *
 * @param reader
 * @param delimiter
 * @return a CSV reader which uses the delimiter provided
 */
private static CSVReader<String[]> buildCSVReader(Reader reader, char delimiter) {
    try {
        // Mark the reader stream to read 1 character ahead, so that we can reset to that point if the first character is not UTF-8 BOM
        reader.mark(1);

        int read = reader.read();

        if (read != 0xFEFF) {
            reader.reset();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return new CSVReaderBuilder<String[]>(reader).entryParser(new DefaultCSVEntryParser()).strategy(SimpleBulkObjectReader.createStrategyWithDelimiter(delimiter)).build();
}
 
开发者ID:BingAds,项目名称:BingAds-Java-SDK,代码行数:23,代码来源:SimpleBulkObjectReader.java


示例2: getPosts

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
@Override
   public List<PostCSV> getPosts() {

List<PostCSV> posts_list = null;
try {
    reader = new FileReader(filePath);

    CSVEntryParser<PostCSV> entryParser = new AnnotationEntryParser<PostCSV>(PostCSV.class, provider);
    CSVReader<PostCSV> csvPostReader = new CSVReaderBuilder<PostCSV>(reader).entryParser(entryParser).build();

    posts_list = csvPostReader.readAll();
} catch (IOException e) {
    System.out.println("Exception while reading" + e);
    e.printStackTrace();
}

return posts_list;
   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:19,代码来源:ERSCSVParser.java


示例3: getUsers

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
@Override
   public List<UserCSV> getUsers() {
List<UserCSV> userList = null;
try {
    reader = new FileReader(filePath);
    
    CSVEntryParser<UserCSV> entryUserParser = new AnnotationEntryParser<UserCSV>(UserCSV.class, provider);
    CSVReader<UserCSV> csvUserReader = new CSVReaderBuilder<UserCSV>(reader)
	    .entryParser(entryUserParser).build();

    userList = csvUserReader.readAll();
} catch (IOException e) {
    e.printStackTrace();
}
return userList;
   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:17,代码来源:ERSCSVParser.java


示例4: testeTempo

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public static void testeTempo() throws IOException{
	int ano = 2014, mes = 05, dia = 21;
	String local = "LPFR";
	URL oracle = new URL("http://www.wunderground.com/history/airport/"+local+"/"+ano+"/"+mes+"/"+dia+"/DailyHistory.html?format=1");
	//http://www.wunderground.com/history/airport/KSAN/2012/10/1/MonthlyHistory.html?format=1
       BufferedReader reader = new BufferedReader(new InputStreamReader(oracle.openStream()));
	CSVReader<String[]> csvParser = CSVReaderBuilder.newDefaultReader(reader);
	List<String[]> data = csvParser.readAll();
	
	for(String[] strs : data){
		for(String str : strs){
			System.out.print(str+";");
		}
		System.out.println();
	}
}
 
开发者ID:zpankr,项目名称:SmartBetSystem,代码行数:17,代码来源:Util.java


示例5: read

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public CoolRecord[] read() throws Exception {

		ArrayList<CoolRecord> records = new ArrayList<CoolRecord>();
		Reader reader = new FileReader(csvFileURI);
		CSVReader<String[]> csvReader = new CSVReaderBuilder<String[]>(reader)
				.entryParser(new DefaultCSVEntryParser())
				.strategy(CSVStrategy.UK_DEFAULT).build();

		boolean hasColumnRowSkipped = false;
		for (String[] csvReaderRecord : csvReader.readAll()) {

			if (!hasColumnRowSkipped) {
				hasColumnRowSkipped = true;
				continue;
			}

			CoolRecord record = null;

			// Column Detail is not provided by user. So, default is set to
			// String for all columns
			if (columns == null || columns.length < 0) {

				columns = new CoolColumn[csvReaderRecord.length];
				for (int i = 0; i < columns.length; i++) {
					columns[i] = new CoolColumn(null, i, String.class);
				}
			}
			record = new CoolRecord(columns, csvReaderRecord);

			records.add(record);
		}

		return records.toArray(new CoolRecord[records.size()]);
	}
 
开发者ID:realsoelynn,项目名称:CoolReader,代码行数:35,代码来源:CSVDataSource.java


示例6: readAllUsing

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
protected List<T> readAllUsing(CSVEntryParser<T> csvEntryParser, InputStream content) throws IOException {
    checkArgument(csvEntryParser != null, "Expected non-null csvEntryParser argument");
    checkArgument(content != null, "Expected non-null content argument");
    Reader reader = new InputStreamReader(content);
    CSVReader<T> csvReader = new CSVReaderBuilder<T>(reader)
            .strategy(csvStrategy)
            .entryParser(csvEntryParser)
            .build();
    return csvReader.readAll();
}
 
开发者ID:OtwartaPlatformaWyborcza,项目名称:OPW-backend-JavaEE,代码行数:11,代码来源:AbstractCSVReader.java


示例7: parseCsvFile

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
private List<TweetToSchedule> parseCsvFile(String pathToCsvFile) {
    List<TweetToSchedule> csvData = null;
    Reader reader = inputReader.getInputReader(pathToCsvFile);
    CSVReader<TweetToSchedule> csvParser = createCSVReader(reader);
    try {
        csvData = csvParser.readAll();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return csvData;
}
 
开发者ID:jstanier,项目名称:tweet-scheduler,代码行数:12,代码来源:InputParser.java


示例8: create

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public static void create(){
try {
	//URI uri = DatabaseConnection.class.getResource("/db").toURI();
	//File folder = new File("db");
          InputStream listInputStream = DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/db/list.txt");
          BufferedReader listReader = new BufferedReader(new InputStreamReader(listInputStream));

          Map<String,InputStream> inputStreamMap = new HashMap<>();
          String name;
          while ((name = listReader.readLine()) != null) {
              inputStreamMap.put(name, DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/db/" + name));
          }

	anos = new String[inputStreamMap.size()];
          int idx = 0;
          for (Map.Entry<String, InputStream> entry : inputStreamMap.entrySet()){
              InputStream is = entry.getValue();
              String fName = entry.getKey();
              anos[idx] = fName.substring(0, 4);
              idx++;
              Reader reader = new InputStreamReader(is);
              CSVReader<String[]> csvParser = CSVReaderBuilder.newDefaultReader(reader);
              List<String[]> data = csvParser.readAll();
              db.add(data);
          }
	
	itemsToAdd = CSVReaderBuilder.newDefaultReader(new InputStreamReader(DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/knap/items.csv"))).readAll();
	equipas = CSVReaderBuilder.newDefaultReader(new InputStreamReader(DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/knap/equipas.csv"))).readAll();
	sites = CSVReaderBuilder.newDefaultReader(new InputStreamReader(DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/knap/sites.csv"))).readAll();
	neuralScores = CSVReaderBuilder.newDefaultReader(new InputStreamReader(DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/knap/neural.csv"))).readAll();
	resultados = CSVReaderBuilder.newDefaultReader(new InputStreamReader(DatabaseConnection.class.getResourceAsStream("/main/resources/tsi/knap/resultados.csv"))).readAll();
} catch (IOException e) {
	e.printStackTrace();
}
  }
 
开发者ID:zpankr,项目名称:SmartBetSystem,代码行数:36,代码来源:DatabaseConnection.java


示例9: createReader

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
protected CSVReader<SeriesValue> createReader() throws IOException
{
    CSVReaderBuilder<SeriesValue> builder = new CSVReaderBuilder<SeriesValue>(new InputStreamReader(storage.read()));

    builder.strategy(UK_DEFAULT);
    builder.entryParser(new AnnotationEntryParser<SeriesValue>(SeriesValue.class, new ValueProcessorProvider()));

    return builder.build();
}
 
开发者ID:andrey-vorobiev,项目名称:hudson-graph-plugin,代码行数:10,代码来源:SeriesValueStorage.java


示例10: build

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
/**
    * This method finally creates the CSVReaderImpl using the specified configuration.
    * 
    * @return the CSVReaderImpl instance
    */
   @Override
   public CSVReader<E> build() {
if (this.entryParser == null) {
    throw new IllegalStateException("you have to specify a csv entry parser");
}

return new CSVReaderImpl<E>(this);
   }
 
开发者ID:trein,项目名称:gtfs-java,代码行数:14,代码来源:CSVReaderBuilder.java


示例11: build

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
/**
    * This method finally creates the CSVReaderImpl using the specified configuration.
    * 
    * @return the CSVReaderImpl instance
    */
   @Override
   public CSVReader<E> build() {
if (this.entryParser == null) {
    throw new IllegalStateException("you have to specify a csv entry parser");
}

return new CSVHeaderAwareReader<E>(this);
   }
 
开发者ID:trein,项目名称:gtfs-java,代码行数:14,代码来源:CSVHeaderAwareReaderBuilder.java


示例12: setUp

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
@Before
   public void setUp() throws Exception {
Reader reader = new InputStreamReader(this.getClass().getResourceAsStream("/persons.csv"));
CSVStrategy strategy = new CSVStrategy(';', '"', '#', true, true);
CSVReader<Person> csvReader = new CSVReaderBuilder<Person>(reader).entryParser(new PersonEntryParser())
        .strategy(strategy).build();
this.cachedReader = new CachedCSVReaderImpl<Person>(csvReader);
   }
 
开发者ID:trein,项目名称:gtfs-java,代码行数:9,代码来源:CachedCSVReaderImplTest.java


示例13: createNextEntityReader

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
private CSVReader<?> createNextEntityReader() {
    LOGGER.info("Loading file [{}]", this.currentEntityClass);
    String path = getEntityFilePath();
    InputStream stream = getClass().getClassLoader().getResourceAsStream(path);
    Reader csv = new InputStreamReader(stream);
    ValueProcessorProvider processor = new ValueProcessorProvider();
    CSVHeaderAwareEntryParser<Object> entryParser = new CSVHeaderAwareEntryParser<Object>(this.currentEntityClass, processor);
    return new CSVHeaderAwareReaderBuilder<Object>(csv).entryParser(entryParser).build();
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:10,代码来源:GtfsItemReader.java


示例14: createBulkFileReader

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public static BulkFileReader createBulkFileReader(CSVReader<String[]> csvReader, BulkObjectFactory factory) throws FileNotFoundException {
    BulkFileReader fileReader = new BulkFileReader(new SimpleBulkStreamReader(new SimpleBulkObjectReader(csvReader, factory)), ResultFileType.PARTIAL_DOWNLOAD);

    return fileReader;
}
 
开发者ID:BingAds,项目名称:BingAds-Java-SDK,代码行数:6,代码来源:TestFactory.java


示例15: createCSVReader

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private CSVReader<TweetToSchedule> createCSVReader(Reader reader) {
       return (CSVReader<TweetToSchedule>) new CSVReaderBuilder(reader)
               .strategy(CSVStrategy.UK_DEFAULT)
               .entryParser(new TweetToScheduleEntryParser()).build();
   }
 
开发者ID:jstanier,项目名称:tweet-scheduler,代码行数:7,代码来源:InputParser.java


示例16: read

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public List<SeriesValue> read() throws IOException
{
    CSVReader<SeriesValue> reader = createReader();

    return reader.readAll();
}
 
开发者ID:andrey-vorobiev,项目名称:hudson-graph-plugin,代码行数:7,代码来源:SeriesValueStorage.java


示例17: loadSeries

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
@Override
protected List<SeriesValue> loadSeries(AbstractBuild build) throws IOException
{
    List<SeriesValue> values = new ArrayList<SeriesValue>();

    FilePath seriesFile = new FilePath(build.getWorkspace(), getFile());

    try
    {
        if (!seriesFile.exists())
        {
            return values;
        }

        CSVReader<String[]> reader = null;

        try
        {
            reader = new CSVReaderBuilder<String[]>(new InputStreamReader(seriesFile.read())).strategy(CSVStrategy.UK_DEFAULT).entryParser(new DefaultCSVEntryParser()).build();

            List<String> headers = reader.readHeader();

            for (String[] row; (row = reader.readNext()) != null;)
            {
                if (row.length == 0 || row[0].isEmpty())
                {
                    continue;
                }

                for (Integer columnIndex = 0; columnIndex < row.length; columnIndex++)
                {
                    String header = headers.get(columnIndex);

                    if (shouldIncludeColumn(header, columnIndex.toString()))
                    {
                        values.add(new SeriesValue(row[columnIndex], header, build));
                    }
                }

                break;
            }
        }
        finally
        {
            if (reader != null)
            {
                reader.close();
            }
        }

        return values;
    }
    catch (InterruptedException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:andrey-vorobiev,项目名称:hudson-graph-plugin,代码行数:58,代码来源:CSVSeries.java


示例18: CSVIterator

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public CSVIterator(CSVReader<E> reader) {
this.reader = reader;
   }
 
开发者ID:trein,项目名称:gtfs-java,代码行数:4,代码来源:CSVIterator.java


示例19: CachedCSVReaderImpl

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
public CachedCSVReaderImpl(CSVReader<E> reader) {
this.reader = reader;
this.cachedEntries = new ArrayList<E>();

this.currentIndex = -1;
   }
 
开发者ID:trein,项目名称:gtfs-java,代码行数:7,代码来源:CachedCSVReaderImpl.java


示例20: createFakeCsvReader

import com.googlecode.jcsv.reader.CSVReader; //导入依赖的package包/类
private CSVReader<String[]> createFakeCsvReader(Iterator<String[]> iterator) {
    CSVReader<String[]> reader = createNiceMock(CSVReader.class);
    
    expect(reader.iterator()).andReturn(iterator);
    
    replay(reader);

    return reader;
}
 
开发者ID:BingAds,项目名称:BingAds-Java-SDK,代码行数:10,代码来源:ReadWriteEntitiesWithErrorsTest.java



注:本文中的com.googlecode.jcsv.reader.CSVReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Result类代码示例发布时间:2022-05-22
下一篇:
Java SerializedExceptionProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap