Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I have a CSV file which I would like to import into a SQLite database. I see that this can be done via the SQLite command line. However, I was wondering if it's possible to import the CSV via javascript.

Currently, I'm using the sql.js library to interface with SQLite from Javascript.

Thanks in advance!

share|improve this question
    
why not just use ruby's csv library? here's an example : sitepoint.com/guide-ruby-csv-library-part – rb512 Apr 25 at 19:53
    
Thanks. But the CSV file I have is huge and so, I dont want to store it in memory. At the same time, I would need to query random bits of info from this data. This is the reason I prefer to store it on disk (to reduce memory usage) and in a database (for efficient querying). As I understand, the ruby library is just to parse the CSV file line by line, right? As in, I dont think it would be enable to achieve the twin goals of reducing memory usage and efficient querying, right? Or have i missed something? – jithinpt Apr 25 at 21:28

2 Answers 2

I was wondering if it's possible to import the CSV via javascript

Yes it is possible, csv is just data, and sqlite is a database, so yes you can put data in to the database.

You just need to figure out how you want to store the data first, then read the csv data, format it accordingly, and save it to your sqlite db.

There are a number of javascript libraries for reading csv data on npm.

share|improve this answer

Yes it possible. If you are using nodejs then install the npm csv Package and install the package.
then just require the package in you program and save the csv file data according to you requirement.

npm csv

It can handle the large data.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.