csv文件内容如下,第一行是文件头

解析代码如下:

package com.xxx;

import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; @Data
public class CodecRegistries {
private String index;
private String name;
/**
* WAVE form Registration Number
*/
private Integer hex;
/***
* Codec ID in the IANA Namespace
*/
private String mimeType; /***
* WAVE form wFormatTag ID
*/
private String wFormatTag; /***
* WAVEFORMAT Use
*/
private String use; /***
* WAVEFORMAT Name
*/
private String formatName; /***
* WAVEFORMAT Description
*/
private String descr; /***
* Additional Information
*/
private String additional; /***
*
*/
private String contact; @Override
public String toString() {
return new ToStringBuilder(this)
.append("index", index)
.append("name", name)
.append("hex", hex)
.append("mimeType", mimeType)
.append("wFormatTag", wFormatTag)
.append("use", use)
.append("formatName", formatName)
.append("descr", descr)
.append("additional", additional)
.append("contact", contact)
.toString();
}
}
static Map<Integer,CodecRegistries> codes = new HashMap<>();

 static void readCodeRegistries(String fileName)
{
try (InputStream inputStream = new FileInputStream(fileName)) { FileSource source = FileSource.of(inputStream); CsvParserConfig config = CsvParserConfig.builder()
.charset(StandardCharsets.UTF_8)
.build(); Map<Integer, CodecRegistries> map = Windmill.parse(source, Parsers.csv(config)).skip(1).map(row -> {
CodecRegistries registration = new CodecRegistries(); registration.setIndex(row.cell(0).asString());
registration.setName(row.cell(1).asString());
          //通过自定义数据转换代码,将16进制数0x0001这样的数值转换成Integer
Integer hex = new NumberValue<Integer>(row.cell(2).asString(), hexDecimal -> Integer.decode(hexDecimal)).value(); registration.setHex(hex);
registration.setMimeType(row.cell(3).asString());
registration.setWFormatTag(row.cell(4).asString());
registration.setUse(row.cell(5).asString());
registration.setFormatName(row.cell(6).asString());
registration.setDescr(row.cell(7).asString());
registration.setAdditional(row.cell(8).asString());
registration.setContact(row.cell(9).asString());
return registration; }).collect(Collectors.toMap(CodecRegistries::getHex, Function.identity()));
codes.putAll(map);
}catch (IOException e){
System.err.println(e);
}
}

csv解析框架Windmill的一个demo的更多相关文章

  1. Android 打造编译时注解解析框架 这只是一个开始

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/43452969 ,本文出自:[张鸿洋的博客] 1.概述 记得很久以前,写过几篇博客 ...

  2. C 封装一个csv 解析库

    引言 最经关于基础C开发框架基本都搭建好了. 在研究githup,准备传上去. 可惜的是两会连githup 都登陆不进去. 三观很正的我也觉得, 这样不好. 双向标准, 共x党不是一个代表穷苦大众的党 ...

  3. 开源一个CSV解析器(附设计过程 )

    在ExcelReport支持csv的开发过程中,需要一个NETStandard的csv解析器.在nuget上找了几个试用,但都不太适合. 于是,便有了:AxinLib.IO.CSV. 先看看怎么用: ...

  4. 干货!表达式树解析"框架"(3)

    最新设计请移步 轻量级表达式树解析框架Faller http://www.cnblogs.com/blqw/p/Faller.html 这应该是年前最后一篇了,接下来的时间就要陪陪老婆孩子了 关于表达 ...

  5. springMvc的第一个demo

    1.下载jar包 http://repo.spring.io/libs-release-local/org/springframework/spring/4.2.3.RELEASE/ 2.下载源码 j ...

  6. Angular2 不明真相第一个Demo例子

    如果不是去年换工作接触到AngularJS,估计是不会花时间去学习这个框架的,毕竟是前端的框架,不是自己熟悉的领域.但是为了混得下去,去年就学习了AngularJS的一些用法,当时还整理了一些积累 & ...

  7. springboot使用fastJson作为json解析框架

    springboot使用fastJson作为json解析框架 springboot默认自带json解析框架,默认使用jackson,如果使用fastjson,可以按照下列方式配置使用 〇.搭建spri ...

  8. 轻量级表达式树解析框架Faller

    有话说 之前我写了3篇关于表达式树解析的文章 干货!表达式树解析"框架"(1) 干货!表达式树解析"框架"(2) 干货!表达式树解析"框架" ...

  9. 干货!表达式树解析"框架"(1)

    最新设计请移步 轻量级表达式树解析框架Faller http://www.cnblogs.com/blqw/p/Faller.html 关于我和表达式树 其实我也没有深入了解表达式树一些内在实现的原理 ...

随机推荐

  1. OpenGL学习脚印: uniform blocks在着色器中的使用 转自https://blog.csdn.net/wangdingqiaoit/article/details/52717963

    写在前面 目前,我们在着色器中要传递多个uniform变量时,总是使用多个uniform,然后在主程序中设置这些变量的值:同时如果要在多个shader之间共享变量,例如投影矩阵projection和视 ...

  2. less-important

    !important关键字:会为所有混合带来的样式,添加!important 在css里面加上!important,是所有样式优先级最高的 在less里面什么场景会用important,在调试的时候 ...

  3. Java与CC++交互JNI编程

    哈哈,经过了前面几个超级枯燥的C.C++两语言的基础巩固之后,终于来了到JNI程序的编写了,还是挺不容易的,所以还得再接再厉,戒骄戒躁,继续前行!! 第一个JNI程序: JNI是一种本地编程接口.它允 ...

  4. 单元测试框架之unittest(四)

    一.摘要 假设我们有一组测试方法差别非常小,比如仅仅是所需要的参数有少许变化时,我们的自动化测试如何进行?unittest框架为这种场景提供了一种方式,它允许我们用subTest()上下文管理器在一个 ...

  5. http协议头

    1. ctx->AddResponseHeader("Content-Type", "application/octet-stream"); ctx-&g ...

  6. MongoDB常用语句大全

    原文出处:https://www.cnblogs.com/--smile/p/11055204.html 直接输入mongo进入数据库 查询操作 查看当前数据库版本 db.version() //4. ...

  7. 第69题:x的平方根

    一. 问题描述 实现 int sqrt(int x) 函数. 计算并返回 x 的平方根,其中 x 是非负整数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. 示例 1: 输入: 4 输 ...

  8. Python 10.1.1

  9. 【leetcode】1240. Tiling a Rectangle with the Fewest Squares

    题目如下: Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile th ...

  10. 使用std::function改善模板的低效性

    泛型编程中,模板会根据传入类型的不同,生成多种实例,相对低效. 模板编程: #include <iostream> using namespace std; //未使用函数包装器 temp ...