Problem while Importing a csv file into the database

1,126 views
Skip to first unread message

Saurabh S

unread,
Nov 2, 2011, 7:36:27 AM11/2/11
to web2py-users
Hi,
I am facing the problem while importing csv file. Please find the
steps below that i am following.

Step1: Created table headers(cloumns) in the excel file EXACTLY
SIMILAR to those which are present in the database table

Step2: Inserted some dummy data as rows in the columns. All the
validations are taken care of while creating/filling out the dummy
rows.
For example: Inserted values in rows where the validation on field
was "not null =True"

Step3: Saved the file with .csv extension

Step4: Tried to import this .csv file into the database using /
appadmin


It is been observed that no data has been inserted into the database
table. Also there was no error message displayed.

Questions:
1. What is the correct way to create the CSV file so that the file can
be imported using appadmin feature.
2. How to debug the error in case data is not reflected after
importing the .csv file?
3. Is there any particular steps that needs to be followed while
importing the file. Please share the documentation/reference in case
it is available.

Johann Spies

unread,
Nov 3, 2011, 2:38:36 AM11/3/11
to web...@googlegroups.com
On 2 November 2011 13:36, Saurabh S <ggtes...@gmail.com> wrote:
Questions:
1. What is the correct way to create the CSV file so that the file can
be imported using appadmin feature.
2. How to debug the error in case data is not reflected after
importing the .csv file?
3. Is there any particular steps that needs to be followed while
importing the file. Please share the documentation/reference in case
it is available.


What I normall do is to create an empty table, use the admin function  to export it to a csv-file, open the file in a spreadsheet and populate the columns - but I leave the data in the 'id' column empty.

If I am struggling to get this working in using the admin interface I try it on the commandline where it is a bit easier to debug.

There were cases that I could not import csv files (created by web2py) on another computer.  As a last resort I just did a dump of the table using Postgresql and imported the dump using 'psql -f <filename> dbname'

Regards
Johann



--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Saurabh S

unread,
Nov 3, 2011, 5:01:45 AM11/3/11
to web...@googlegroups.com
Hi , thanks for the reply...i tried what you suggested but even that is not working out...is there any other solution for this ? please suggest as i am complately stuck up with this from last three days....plz suggest

Philip Kilner

unread,
Nov 3, 2011, 5:27:22 AM11/3/11
to web...@googlegroups.com
Hi,

On 03/11/2011 09:01, Saurabh S wrote:
> is there any other solution for this ? please suggest
> as i am complately stuck up with this from last three days....plz suggest
>

I can't help with web2py's CSV import function, but if you are stuck,
why not try importing directly into the database?

You don't say what database you using, but if you can share that it
should be possible to suggest a tool to talk to the database directly.


--

Regards,

PhilK


'a bell is a cup...until it is struck'

Saurabh S

unread,
Nov 3, 2011, 7:12:57 AM11/3/11
to web...@googlegroups.com
Thanks for replying philip,
I will be deploying my code to GAE....database will be Google's datastore...is there any tool available to migrate a data template into GAE datastore ?

Philip Kilner

unread,
Nov 3, 2011, 7:52:04 AM11/3/11
to web...@googlegroups.com
Hi,

On 03/11/2011 11:12, Saurabh S wrote:
> I will be deploying my code to GAE....database will be Google's
> datastore...is there any tool available to migrate a data template into
> GAE datastore ?
>

I'm not familiar with tools for GAE, although a quick Google suggests
that there are some, but I'd expect to be able to use web2py's upload
for that.

FWIW, although most RDBMSs have decent tools, I use dbVis for this: -

http://www.dbvis.com/

...but it only supports traditional databases.

Going back to your original import problem: -

Is it failing running locally?

Against SQLite (default), local AppEngine environment, or something else?

Can you share the first couple of lines of your CSV as a sanity check?

howesc

unread,
Nov 3, 2011, 2:55:39 PM11/3/11
to web...@googlegroups.com
what is the error you are getting when you upload the data?

note that web2py CSV import will be limited to what can be processed in 30 seconds, which limits you to around 100 rows.

http://code.google.com/appengine/docs/python/tools/uploadingdata.html is my favorite.  use the tool to generate the bulkload.yaml and then download and upload.  there is trickiness if you have blobstore items you are trying to sync between databases, let me know if you need info on that too.
Reply all
Reply to author
Forward
0 new messages