Java解析在Java - 工作示例..? [英] CSV parsing in Java - working example..?

查看:102
本文介绍了Java解析在Java - 工作示例..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为一个学校的java项目编写一个程序来解析一些我不知道的CSV。我知道每列的数据类型 - 虽然我不知道分隔符。

I want to write a program for a school java project to parse some CSV I do not know. I do know the datatype of each column - although I do not know the delimiter.

我不知道如何解决的问题是解析日期或甚至DateTime列。

The problem I do not even marginally know how to fix is to parse Date or even DateTime Columns. They can be in one of many formats.

我找到了许多库,但没有任何线索,这是我最需要的:
http://opencsv.sourceforge.net/
http://www.csvreader.com/java_csv.php
http://supercsv.sourceforge.net/
http://flatpack.sourceforge。 net /

I found many libraries but have no clue which is the best for my needs: http://opencsv.sourceforge.net/ http://www.csvreader.com/java_csv.php http://supercsv.sourceforge.net/ http://flatpack.sourceforge.net/

问题是我是一个java初学者。恐怕不是那些图书馆可以做我需要的,或者我不能说服他们这样做。

The problem is I am a total java beginner. I am afraid non of those libraries can do what I need or I can't convince them to do it.

我打赌有很多人在这里有代码

I bet there are a lot of people here who have code sample that could get me started in no time for what I need:


  • 自动拆分为列(分隔符未知,Columntypes是已知的)

  • 投放到Columntype(应该处理$,%等)

  • 将日期转换为Java日期或日历对象

很高兴通过电子邮件获取尽可能多的代码示例。

It would be nice to get as many code samples as possible by email.

非常感谢!
AS

Thanks a lot! AS

推荐答案

您还拥有 Apache Commons CSV 库,也许它做你需要的。请参见指南。在2014-11更新到1.1版。

You also have the Apache Commons CSV library, maybe it does what you need. See the guide. Updated to Release 1.1 in 2014-11.

此外,对于傻瓜版本,我想你需要自己编码...通过 SimpleDateFormat 你可以选择你的格式,并指定各种类型,如果 Date 不像你的任何预想类型,它不是一个日期。

Also, for the foolproof edition, I think you'll need to code it yourself...through SimpleDateFormat you can choose your formats, and specify various types, if the Date isn't like any of your pre-thought types, it isn't a Date.

这篇关于Java解析在Java - 工作示例..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆