首页 > 其他分享 >数据处理日志

数据处理日志

时间:2023-01-15 17:00:10浏览次数:43  
标签:String route content lineStr time 数据处理 日志 RRT

数据处理日志

 

package com.vfsd.core;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.Charset;

import com.csvreader.CsvWriter;

public class LXTxtDataToCsv {
    public static String[] headers = {"","开始时间","结束时间","开始时间","结束时间","路径节点数量","路径欧式长度","路径曼哈顿长度","原始节点数量","开始时间","结束时间","路径节点数量","路径欧式长度","路径曼哈顿长度","原始节点数来明"};
    public static String[] content = {"","","","","","","","","","","","","","",""};
    public static String txtFilePath = "D:\\pts_data\\2022100501\\data_2023010702.txt";
    public static String csvFilePath = "D:\\pts_data\\2022100501\\data_2023010702.csv";
    public static CsvWriter csvWriter = null;
    
    
    public static void main(String[] args){
        csvWriter = new CsvWriter(csvFilePath,',', Charset.forName("UTF-8"));
        try {
            csvWriter.writeRecord(headers);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        try {
            readTxtFile();
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        
        try {
            csvWriter.flush();
            csvWriter.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        System.out.println("读写完毕...");
    }
    
    /***
     * 
     * @throws Exception
     */
    public static void readTxtFile() throws Exception {
        File txtFile = new File(txtFilePath);
        FileReader fileReaderObj = new FileReader(txtFile);
        BufferedReader bufferedReaderObj = new BufferedReader(fileReaderObj);
        
        String lineStr="";
        boolean groupDataStart = true;
        
        String jiantu_start_time = "";
        String jiantu_end_time = "";
        
        String AStar_start_time = "";
        String AStar_end_time = "";
        String AStar_route_num = "";
        String AStar_route_length1 = "";
        String AStar_route_length2 = "";
        
        String RRT_start_time = "";
        String RRT_end_time = "";
        String RRT_route_num = "";
        String RRT_route_length1 = "";
        String RRT_route_length2 = "";
        
        while((lineStr=bufferedReaderObj.readLine())!=null) {
            if(lineStr.startsWith("=")) {
                groupDataStart = true;
            }else {
                groupDataStart = false;
            }
            
            if(groupDataStart) {
                //建图开始时间:09:16:22      建图结束时间:09:16:28
                lineStr=bufferedReaderObj.readLine();
                String[] jiantu_time = lineStr.split("时间:");
                jiantu_start_time = jiantu_time[1].replaceAll(" ", "").replace("建图结束", "");
                jiantu_end_time = jiantu_time[2].replaceAll(" ", "");
                
                
                //A*开始时间:09:16:36      A*结束时间:09:16:37
                lineStr=bufferedReaderObj.readLine();
                String[] AStrt_time = lineStr.split("时间:");
                AStar_start_time = AStrt_time[1].replaceAll(" ", "").replace("A*结束", "");
                AStar_end_time = AStrt_time[2].replaceAll(" ", "");
                
                
                //原始路径节点数量:15
                lineStr=bufferedReaderObj.readLine();
                String[] astar_route_num = lineStr.split(":");
                AStar_route_num = astar_route_num[1].replaceAll(" ", "");
                
                lineStr=bufferedReaderObj.readLine();
                
                //A*路径实际长度:30189.9                      A*路径曼哈顿长度:6362.07
                lineStr=bufferedReaderObj.readLine();
                String[] AStrt_route_length = lineStr.split(":");
                AStar_route_length1 = AStrt_route_length[1].replaceAll(" ", "").replace("A*路径曼哈顿长度", "");
                AStar_route_length2 = AStrt_route_length[2].replaceAll(" ", "");
                
                
                //RRT开始时间:09:16:57      RRT结束时间:09:17:01
                lineStr=bufferedReaderObj.readLine();
                String[] rrt_time = lineStr.split("时间:");
                RRT_start_time = rrt_time[1].replaceAll(" ", "").replace("RRT结束", "");
                RRT_end_time = rrt_time[2].replaceAll(" ", "");
                
                //原始路径节点数量:15
                lineStr=bufferedReaderObj.readLine();
                String[] rrt_route_num = lineStr.split(":");
                RRT_route_num = rrt_route_num[1].replaceAll(" ", "");
                
                lineStr=bufferedReaderObj.readLine();
                
                //RRT路径实际长度:23706                      RRT路径曼哈顿长度:6362.07
                lineStr=bufferedReaderObj.readLine();
                String[] rrt_route_length = lineStr.split("长度:");
                RRT_route_length1 = rrt_route_length[1].replaceAll(" ", "").replace("RRT路径曼哈顿", "");
                RRT_route_length2 = rrt_route_length[2].replaceAll(" ", "");
                
                content[1] = jiantu_start_time;
                content[2] = jiantu_end_time;
                content[3] = AStar_start_time;
                content[4] = AStar_end_time;
                content[5] = AStar_route_num;
                
                content[6] = AStar_route_length1;
                content[7] = AStar_route_length2;
                content[8] = "";
                content[9] = RRT_start_time;
                content[10] = RRT_end_time;
                
                content[11] = RRT_route_num;
                content[12] = RRT_route_length1;
                content[13] = RRT_route_length2;
                content[14] = "";
                
                csvWriter.writeRecord(content);
                csvWriter.flush();
                
            }else {
                continue;
            }
            
        }
        
    }

}

 

 

 

##############################

标签:String,route,content,lineStr,time,数据处理,日志,RRT
From: https://www.cnblogs.com/herd/p/17044623.html

相关文章

  • 温习日志-3
    温习日志——2023年1月15日上午学习内容语句与表达式语句只执行代码,而不返回值如果在语句中声明变量,会产生块级作用域,外部访问不到块级作用域中的局部变量表达式是......
  • 【oracle】ORA-12541: TNS: 无监听程序——监听日志太大/任务管理器服务里停监听删日
    可能性1:原因:监听日志的达到4g解决办法: 停监听,删日志,重启监听 ......
  • Linux中查看日志的常用命令
    grep#遍历查看当前目录下所有文件中包含xxx的语句grep-rxxx.#查询文件中包含xxx的语句grepxxxfile_name#查询多个文件中包含xxx的语句grepxxxfile1fi......
  • [VueJsDev] 日志 - 更新日志
    更新日志:::details目录目录​更新日志​​​Log.1:安装了宝塔​​​​Log.2:Markdown语法​​​​Log.3:站点环境​​​​Log.4:服务器环境​​​​Log.5:服......
  • [VueJsDev] 日志 - BBTime-LOG
    BBTime-LOG:::details目录目录​BBTime-LOG​​​Log.1:AutoNumber成功发布到vscode插件市场了​​​​Log.2:AutoNumber.js改成vscode插件了​​​​Log.3:复盘总......
  • 温习日志-1
    温习日志——2023年1月13日晚b站学习地址学习内容​ 前面视频都是代码开发环境以及相关配置的设置JS、CSS、HTML的关系相当于英语中的HTML(名词),CSS(形容词),JS(动......
  • 温习日志-2
    温习日志——2023年1月14日下午b站学习地址学习内容let和const命令1.在平常使用中我们使用let命令声明变量1.对于let命令声明的变量我们可以自由地赋值为其他的......
  • 图文结合带你搞懂MySQL日志之relay log(中继日志)
    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源。GreatSQL是MySQL的国产分支版本,使用上与MySQL一致。作者:KAiTO文章来源:GreatSQL社区原创什么......
  • 日志打包压缩
    这几天,服务器日志涨的很快。因为没有日志服务器,都是写在本地。要保留三个月,打包,压缩能节省些空间。做个记录。#找到当前时间前一天的文件,打包压缩#路径/opt/logs/mns/a......
  • loguru日志模块使用
    相比于logging模块,loguru模块使用起来更方便,并且可以根据不同日志级别,进行不同颜色输出一、安装pipinstallloguru二、基本使用代码fromloguruimportlogger......