Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8021393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:57:54+00:00 2026-06-04T21:57:54+00:00

What am i doing? I am exporting my sqlite database into a csv —

  • 0

What am i doing? I am exporting my sqlite database into a csv — atleast i try to

I’ve done this both manually and with “OpenCSV”.

With both methods I get very strange results. They just seem not well formatted. Neither the columns (which are usually seperated by ‘,’ ? ) nor special characters (which are said to be handled within opencsv) look like they should. code:

CSVWriter writer = new CSVWriter(new FileWriter(file),'\n',',');

        String[] items = new String[11];
        c.moveToFirst();

        while(!c.isAfterLast()){


        items[0] = c.getString(c.getColumnIndex(BaseColumns._ID));
        items[1] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_QRCODE));
        items[2] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_NAME));
        items[3] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_AMOUNT));
        items[4] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_UNIT));
        items[5] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_PPU));
        items[6] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_TOTAL));
        items[7] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_COMMENT));
        items[8] = c.getString(c.getColumnIndex(DepotTableMetaData.ITEM_SHOPPING));
        items[9] = c.getString(c.getColumnIndex(DepotTableMetaData.CREATED_DATE));
        items[10] = c.getString(c.getColumnIndex(DepotTableMetaData.MODIFIED_DATE));

        c.moveToNext();
        writer.writeNext(items);

        }

        writer.close();

and it all gives this as a result:

enter image description here

I’ve also done it through FileWriter and StringBuffer but it seems to give exactly the same results…I’d love if you could help me 😉

I have looked through stackoverflow but couldn’t find any matching question ;/

edit: yes i know that I use the “old, deprecated” cursor, but that’s not the question here. Thanks.

edit2: SOLVED !
you have to assign some common encoding !

CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(destination+"/output.csv"),"UTF-8"));

did the job perfectly!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:57:56+00:00Added an answer on June 4, 2026 at 9:57 pm

    You use an OpenCSV Writer, which takes a row of the CSV file as an array of Strings, and generates the separators between columns and rows automatically, but instead of letting OpenCSV do it for you, you do it explicitely by appending all the values of a row in a single String. So obviously, OpenCSV takes your unique value and considers it contains a single column, where commas and newlines must be encoded.

    You should call writer.writeNext() with an array of Strings, each String in the array being a single cell from the table. The writer will generate the commas and the newlines for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing the following. 1) I am exporting a database and saving it
I am exporting from a database to excel. While doing so it is exporting
I am doing export of data from database to Excel. After exporting when opening
I'm setting up some html exporting to excel and is doing this via jquery
I am trying to work with dates in an sqlite database. I am storing
When connecting to an SQLite database from Python (using Python 2.6), what strategies are
I am starting doing some directX programming. I am using this tutorial that I
Currently i try to create some of my database export work more automated and
I have a similar problem to this guy: Importing/Exporting Project Preferences , but my
I'm working on a project where we are dealing with importing/exporting data from database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.