Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] the output csv file has a messed up rows #109

Open
anbui08 opened this issue Aug 10, 2016 · 2 comments
Open

[Help] the output csv file has a messed up rows #109

anbui08 opened this issue Aug 10, 2016 · 2 comments

Comments

@anbui08
Copy link

anbui08 commented Aug 10, 2016

Hi everyone.
i am currently using SuperCSV (v 2.4.0) for exporting data.
I am stuck in with the below problem. Could anyone help me to figure out the cause ?

※My problem:

  • My CSV header has 9 columns
    -There is a line which missing a comma dilimiter (,) between two fields, so that line become a 8-columns line
  • The messing line is occur randomly, not exact the same line for every exporting (the data is not change).

※Here my code:
① CSV Writing function
// obmitting

    stmt = con.prepareStatement(sql);
    rs = stmt.executeQuery();

    // obmitting
    // ............

    fos = new FileOutputStream(folderPath + "/" + FILE_NAME);
    osw = new OutputStreamWriter(fos, "EUC-JP");
    beanWriter = new CsvBeanWriter(osw, csvType);
    beanWriter.writeHeader(this.CSV_HEADER);

    while(rs.next()) {
        AttachmentsBean bean = new AttachmentsBean();
        bean.setCompDispId(pMng.getCompDispId());
        bean.setFileId(rs.getString(1));
        bean.setDocumentId(rs.getString(2));
        bean.setFileName(rs.getString(3));
        bean.setDiscription(rs.getString(4));
        bean.setFileSize(rs.getString(5));
        bean.setFilePath(rs.getString(6));
        bean.setMimetype(rs.getString(7));
        bean.setFileOrder(rs.getString(8));
        progressCount++;
        //出力
        beanWriter.write(bean, this.CSV_HEADER);

    }

    //CSV出力終了
    IOUtils.closeQuietly(beanWriter);
    IOUtils.closeQuietly(osw);
    IOUtils.closeQuietly(fos);

    //文字変換
    CommonUtil.convertFile(folderPath, folderPath +"/"+ FILE_NAME);

② ConvertFile helper function
this function is convert special character from EUC to UTF-8

※My question is, is my problem caused by superCSV bug ? can you help to figure out the cause ?
because i have read from the below discussion, not only i met the mess up csv problem, but some one did too.
http://stackoverflow.com/questions/13585914/messed-up-csv-leads-to-exception

@dota17
Copy link
Member

dota17 commented Mar 7, 2020

Hi, @anbui08
Your scenario is: is there a problem with the CSV file generated using the above code?
http://stackoverflow.com/questions/13585914/messed-up-csv-leads-to-exception is that data error causes super-csv to throw exception and block batch processing.

@dota17
Copy link
Member

dota17 commented Mar 17, 2020

Hi, @anbui08
Super CSV doesn't find that the print data is lack of comma. You can try to use the write(Object source, String[] nameMapping, CellProcessor[] processors) method to write, which can verify the number of columns to write data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants