Code Monkey home page Code Monkey logo

dataprocessing's Introduction

本项目为常用数据处理工具类库,解决日常开发中遇到的一些数据处理问题

一、生成测试文件

类:TestDataGenerateUtil

静态方法:

  • generateFile

    public static void generateFile(String outputPath,
                                    int raw,
                                    int column,
                                    String mid,
                                    double dmin,
                                    double dmax,
                                    double n,
                                    int imin,
                                    int imax,
                                    String startDate,
                                    String endDate,
                                    String format,
                                    double doubleRate,
                                    double intRate,
                                    double dateRate,
                                    double sciRate)

    生成随机矩阵文件,包含整数,小数,日期

    • 参数:

      outputPath - 文件输出路径

      raw - 行数

      column - 列数

      mid - 分隔符

      dmin - 浮点型最小值

      dmax - 浮点型最大值

      n - 浮点型保留小数位

      imin - 整型最小值

      imax - 整型组大值

      startDate - 开始时间

      endDate - 结束时间

      format - 日期格式

      doubleRate - 浮点型出现概率

      intRate - 整型出现概率

      dateRate - 时期出现概率

      sciRate - 科学计数法出现概率

  • generateFile

    public static void generateFile(String outputPath,
                                    int raw,
                                    int column,
                                    String mid,
                                    double dmin,
                                    double dmax,
                                    double n,
                                    int imin,
                                    int imax,
                                    double doubleRate,
                                    double intRate,
                                    double sciRate)

    生成一个随机矩阵文件,包括整型,浮点型,科学计数法

    • 参数:

      outputPath - 文件输出路径

      raw - 行数

      column - 列数

      mid - 分隔符

      dmin - 浮点型最小值

      dmax - 浮点型最大值

      n - 浮点型保留小数位

      imin - 整型最小值

      imax - 整型组大值

      doubleRate - 浮点型出现概率

      intRate - 整型出现概率

      sciRate - 科学计数法出现概率

  • generateFile

    public static void generateFile(String outputPath,
                                    int raw,
                                    int column,
                                    String mid,
                                    String startDate,
                                    String endDate,
                                    String format)

    生成一个随机日期矩阵文件

    • 参数:

      outputPath - 文件输出路径

      raw - 行数

      column - 列数

      mid - 分隔符

      startDate - 开始时间

      endDate - 结束时间

      format - 日期格式

  • generateFile

    public static void generateFile(String outputPath,
                                    int raw,
                                    int column,
                                    String mid,
                                    int imin,
                                    int imax)

    生成随机整数矩阵文件

    • 参数:

      outputPath - 文件输出路径

      raw - 行数

      column - 列数

      mid - 分隔符

      imin - 最小值

      imax - 最大值

  • generateFile

    public static void generateFile(String outputPath,
                                    int raw,
                                    int column,
                                    String mid,
                                    double min,
                                    double max,
                                    double n)

    生成随机浮点型矩阵文件

    • 参数:

      outputPath - 文件输出路径

      raw - 行数

      column - 列数

      mid - 分隔符

      min - 最小值

      max - 最大值

      n - 保留小数位数

  • generateFile

    public static void generateFile(String outputPath,
                                    int raw,
                                    int column,
                                    String mid,
                                    double min,
                                    double max,
                                    double n,
                                    double sciRate)

    生成随机浮点型矩阵,含科学计数法

    • 参数:

      outputPath - 文件输出路径

      raw - 行数

      column - 列数

      mid - 分隔符

      min - 最小值

      max - 最大值

      n - 保留小数位数

      sciRate - 生成科学计数法概率

二、数据文件解析

1.文本类文件

类:TextFileUtil

静态方法:

  • getTextFileData

    public static List<Map<String,String>> getTextFileData(File file,String separator)

解析文本类文件

  • 参数:

    file - 文本文件

    separator - 分隔符

  • getTextFileData

    public static List<Map<String,String>> getTextFileData(File file,Integer pos,String separator)

    解析文本类文件

    • 参数:

      file - 文本文件

      pos - 开始行数 不传默认为1

      separator - 分隔符

2.Excel文件

类:OrientExcelUtil

静态方法:

  • getWorkbook

    public static Workbook getWorkbook(File file)

    获取workbook

    • 参数:

      file - excel文件

  • getWorkbook

    public static Workbook getWorkbook(String path)

    获取workbook

    • 参数:

      path - 文件路径

  • getSheetByIndex

    public static Sheet getSheetByIndex(Workbook workbook,int sheetIndex)

    根据sheet下标获取sheet

    • 参数:

      workbook - 工作簿

      sheetIndex - sheet下标

  • getSheetByName

    public static Sheet getSheetByName(Workbook workbook,String sheetName)

根据sheet名称获取sheet

  • 参数:

    workbook - 工作簿

    sheetName - sheet名称

  • getSimpleSheetData

    public static List<Map<String,String>> getSimpleSheetData(Sheet sheet,Integer pos)

    根据header或取sheet数据 key:col,value:cellValue

    • 参数:

      sheet - sheet页

      pos - 从第pos行开始解析,pos默认为1

  • getSimpleSheetData

    public static List<Map<String,String>> getSimpleSheetData(Sheet sheet)

    根据header或取sheet数据 key:col,value:cellValue

    • 参数:

      sheet - sheet页

  • getSimpleSheetDataByRow

    public static List<List<String>> getSimpleSheetDataByRow(Sheet sheet,Integer pos)

    按行获取sheet数据

    • 参数:

      sheet - sheet页

      pos - 数据开始行,默认为1

  • getSimpleSheetDataByRow

    public static List<List<String>> getSimpleSheetDataByRow(Sheet sheet)

    按行获取sheet数据

    • 参数:

      sheet - sheet页

  • getSimpleSheetDataByColumn

    public static List<List<String>> getSimpleSheetDataByColumn(Sheet sheet,Integer pos)

    按列获取sheet数据

    • 参数:

      sheet - sheet页

      pos - 数据开始行,默认为1

  • getSimpleSheetDataByColumn

    public static List<List<String>> getSimpleSheetDataByColumn(Sheet sheet)

    按列获取sheet数据

    • 参数:

      sheet - sheet页

三、绘图

类:ChartPlotUtil

静态方法:

  • createXYLineChart

    public static void createXYLineChart(String title,
                                         String xAxisLabel,
                                         String yAxisLabel,
                                         Map<String,List<Map<String,String>>> data,
                                         String outputPath)

    绘制xy数值型曲线图

    • 参数:

      title - 图表标题

      xAxisLabel - x轴标题

      yAxisLabel - y轴标题

      data - 数据 {"series1":[{"x":1.0,"y":2.0},{"x":2.0,"y":3.0},...],"series1":[{"x":1.0,"y":2.0},{"x":2.0,"y":3.0},...]}

      outputPath - 图片输出路径

  • createXYLineChart

    public static void createXYLineChart(String title,
                                         String xAxisLabel,
                                         String yAxisLabel,
                                         Map<String,List<Map<String,String>>> data,
                                         String outputPath,
                                         Boolean withLegend)

    绘制xy数值型曲线图

    • 参数:

      title - 图表标题

      xAxisLabel - x轴标题

      yAxisLabel - y轴标题

      data - 数据 {"series1":[{"x":1.0,"y":2.0},{"x":2.0,"y":3.0},...],"series1":[{"x":1.0,"y":2.0},{"x":2.0,"y":3.0},...]}

      outputPath - 图片输出路径

      withLegend - 是否显示图例

  • createCategoryLineChart

    public static void createCategoryLineChart(String title,
                                               String xAxisLabel,
                                               String yAxisLabel,
                                               Map<String,List<Map<String,String>>> data,
                                               String outputPath,
                                               Boolean withLegend)

    绘制分类型曲线图

    • 参数:

      title - 图表标题

      xAxisLabel - x轴标题

      yAxisLabel - y轴标题

      data - 数据 {"row1":[{"x":"一月","y":2.0},{"x":"二月","y":3.0},...],"row2":[{"x":"一月","y":2.0},{"x":"二月","y":3.0},...]}

      outputPath - 图片输出路径

      withLegend - 是否显示图例

  • createCategoryLineChart

    public static void createCategoryLineChart(String title,
                                               String xAxisLabel,
                                               String yAxisLabel,
                                               Map<String,List<Map<String,String>>> data,
                                               String outputPath)

    绘制分类型曲线图

    • 参数:

      title - 图表标题

      xAxisLabel - x轴标题

      yAxisLabel - y轴标题

      data - 数据 {"row1":[{"x":"一月","y":2.0},{"x":"二月","y":3.0},...],"row2":[{"x":"一月","y":2.0},{"x":"二月","y":3.0},...]}

      outputPath - 图片输出路径

dataprocessing's People

Contributors

sherlonwang avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.