简体   繁体   English

平面文本文件解析

[英]Flat Text File Parsing

I have a rather complex flat file that I need to parse in Java, but I can't find any libraries that fit my needs. 我有一个相当复杂的平面文件,需要用Java解析,但是找不到适合我需要的库。

Essentially, I have a file consisting of a single line of the format: [num num num num] 本质上,我有一个文件,其中包含以下格式的单行:[num num num num num]
Example: [0.1 0.2 15 30] 示例:[0.1 0.2 15 30]

This is followed by series of two-field CSV formatted lines: num, num 随后是一系列两字段CSV格式的行:num,num
Example: 1.0000E+01, 5.7104E-02 示例:1.0000E + 01、5.7104E-02

This pattern is repeated, so the file consists of blocks that include a header and some data. 重复此模式,因此文件由包括标头和一些数据的块组成。 Here's an example of a whole file (truncated to only three blocks): http://pastebin.com/q3VfRtmF 这是整个文件的示例(仅被截断为三个块): http : //pastebin.com/q3VfRtmF

I need to convert that file into an array of "FluxSet" objects, as defined here: http://pastebin.com/knUFQuVY 我需要将该文件转换为“ FluxSet”对象的数组,如下所示: http ://pastebin.com/knUFQuVY

A Pair is defined here: http://pastebin.com/s5Ehqpab 一对在这里定义: http : //pastebin.com/s5Ehqpab

Does anyone know of a library applicable to this kind of parsing? 有人知道适用于这种解析的库吗?

Thanks, taktoa 谢谢,塔克托

如果输入文件定义正确,则编写一个简单的文件读取器,逐行读取文件,然后执行简单的String.split()Integer.parseInt()或任何其他适用的方法,最后填充所需的文件对象与您刚刚解析的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM