Reputation: 1
I am trying to write some data into a csv file but some of them are written at the end of the line and there is a blank space between each row. I have also tried do collect data into an ArrayList of strings and then use the method csvWriter.writeAll but it gives me the same result.
try(FileWriter fileWriter1 = new FileWriter(csvPath)){
CSVWriter csvWriter = new CSVWriter(fileWriter1);
//Impostazione di Git e della repo.
Git git = Git.open(new File(Cpath));
Repository repository = FileRepositoryBuilder.create(new File(Cpath));
String repo = String.valueOf(repository);
logger.info(repo);
List<Ref> branches = git.branchList().call();
for (Ref ref : branches)
{
logger.info(ref.getName());
}
Iterable<RevCommit> commits = git.log().all().call();
for (RevCommit revCommit : commits) { //itero tutti i commit.
String pattern = "MM/dd/yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern);
String date = df.format(revCommit.getAuthorIdent().getWhen());
String[] columns = {date, revCommit.getFullMessage()};
csvWriter.writeNext(new String[]{date, revCommit.getFullMessage()});
}
csvWriter.flush();
csvWriter.close();
}
Upvotes: 0
Views: 171
Reputation: 149155
The CSV format loosely follows the RFC 4180. But most cvs writers consistenly use a \r\n
(MS/DOS convention) end of file.
When you read that with an editor (or a terminal) that expects only one single \n
for an end of line (Unix convention), you wrongly see additional lines when the file is perfectly correct.
Ref: Wikipedia
Upvotes: 1