-1

I am generating one .csv file from my java code which is coming as a result of one SQL query.The challenge I am facing is one of the column is having very long comment which is spreading to more than one column. But I want that comment to be in one column only.

Please suggest on that.

usha
  • 28,973
  • 5
  • 72
  • 93

2 Answers2

1

Columns in a csv-file are separated by commas, there is no predefined maximum column width, unless the package you use to create your csv implements one. How do you create the csv? If your content spreads over multiple columns, the cause may also be that your comment contains a comma ",".

The best way to deal with this depends on how you generate your csv, and what you intend to do with it (cf this thread).

Community
  • 1
  • 1
i4h
  • 851
  • 7
  • 8
0

I cannot yet comment, so I need to post as an "answer". How are you verifying that it spreads over multiple columns. Do you see this in a display program like Excel or with a print? If you loop over the columns of the row or check len(row) does it show an extra column?

Sometimes, a program like Excel or Libre Office will display the column contents as extending over extra columns even though the data is in only one.

sabbahillel
  • 4,357
  • 1
  • 19
  • 36