commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kranthi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CSV-149) Line number is not proper at EOF
Date Tue, 31 Mar 2015 15:06:52 GMT

    [ https://issues.apache.org/jira/browse/CSV-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14388675#comment-14388675
] 

Kranthi commented on CSV-149:
-----------------------------

Please find the code and output below

Code
=======
public class TestCsv
{
	public static void main(String[] args) throws Exception
	{
		String records = "A,B,C,D\r\n"
				+ "a1,b1,c1,d1\r\n"
				+ "a2,b2,c2,d2";
		
		CSVParser parser = new CSVParser(new StringReader(records), CSVFormat.EXCEL.withHeader());
		Iterator<CSVRecord> recordIt = parser.iterator();
		
		while(recordIt.hasNext())
		{
			System.out.println(parser.getCurrentLineNumber() + " ==> " + recordIt.next());
		}
		
		parser.close();
	}
}

Actual Output
==========
2 ==> CSVRecord [comment=null, mapping={A=0, B=1, C=2, D=3}, recordNumber=1, values=[a1,
b1, c1, d1]]
2 ==> CSVRecord [comment=null, mapping={A=0, B=1, C=2, D=3}, recordNumber=2, values=[a2,
b2, c2, d2]]

Expected Output
==============
2 ==> CSVRecord [comment=null, mapping={A=0, B=1, C=2, D=3}, recordNumber=1, values=[a1,
b1, c1, d1]]
3 ==> CSVRecord [comment=null, mapping={A=0, B=1, C=2, D=3}, recordNumber=2, values=[a2,
b2, c2, d2]]



> Line number is not proper at EOF
> --------------------------------
>
>                 Key: CSV-149
>                 URL: https://issues.apache.org/jira/browse/CSV-149
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.1
>         Environment: CSV 1.1, Java 1.6, Windows OS
>            Reporter: Kranthi
>             Fix For: Patch Needed
>
>
> CSVParser.getCurrentLineNumber() is returning wrong line number (actual line number -
1) when EOF file is reached without record delimiter (\r\n).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message