Re: importing csv data into database

2015-04-26 Thread sum abiut
wow! Thanks heaps Mario :) . it works like a champ, Thank you James and Andrew for the directions. you guys were a great help. Cheers On Mon, Apr 27, 2015 at 12:10 PM, Mario Gudelj wrote: > Remove comma from each line inside the for loop. > On 27/04/2015 10:44 am, "sum abiut" wrote: > >> Hi An

Re: importing csv data into database

2015-04-26 Thread Mario Gudelj
Remove comma from each line inside the for loop. On 27/04/2015 10:44 am, "sum abiut" wrote: > Hi Andrew, > Thanks heaps. do you mine explaining how to fix that. > > cheers, > > On Mon, Apr 27, 2015 at 4:26 AM, Andrew Farrell > wrote: > >> What I'm saying that you are defining data.LastName as a

Re: importing csv data into database

2015-04-26 Thread sum abiut
Hi Andrew, Thanks heaps. do you mine explaining how to fix that. cheers, On Mon, Apr 27, 2015 at 4:26 AM, Andrew Farrell wrote: > What I'm saying that you are defining data.LastName as a tuple and when it > gets turned into a string. So if a row is > > 44, Barack, Obama, 1600 Pennsylvania Avenu

Re: importing csv data into database

2015-04-26 Thread Andrew Farrell
What I'm saying that you are defining data.LastName as a tuple and when it gets turned into a string. So if a row is 44, Barack, Obama, 1600 Pennsylvania Avenue Then data.FirstName is going to be ('Barack',) Which is a single-element tuple. When it gets turned into a string, it becomes ('Barack

Re: importing csv data into database

2015-04-26 Thread sum abiut
i am importing data from csv file to the model test, so i am taking data as an instance of test(). are you saying i should define data as a string?? and have the parameters as personid, firstname,lastname,address. Please advise Cheers On Sun, Apr 26, 2015 at 2:36 AM, Andrew Farrell wrote: > A

Re: importing csv data into database

2015-04-25 Thread Andrew Farrell
Ah, I suppose that bit didn't get sent. Google groups only lets mail from my old gmail address through and bounces mail from the MIT address I use by default. I noticed something else about your code: you are assigning 2-tuples to all of your data types rather than strings when you do data.Pers

Re: importing csv data into database

2015-04-25 Thread sum abiut
Ok , i manage to figure out where the error was coming from in my view.py on line readata=csv.reader(csvfile,delimiter=';', quotechar='|'). The* delimiter =';'* i change the semicolon to a comma The* delimiter =','* and it works. However when the data are imported from the csv file to the model

Re: importing csv data into database

2015-04-23 Thread Andrew Farrell
You might have to make sure that my indentation there is correct. Also, I noticed something else about your code: you are assigning 2-tuples to all of your data types rather than strings when you do data.PersonID=row[0], data.FirstName=row[1], data.LastName=row[2], data.Address=row[3],

Re: importing csv data into database

2015-04-23 Thread Andrew Farrell
could you replace your function with def readcsvfile(request): with open('/var/www/html/webapp/csvupload/data.csv','rb') as csvfile: readata=csv.reader(csvfile,delimiter=';', quotechar='|') #readata=csv.reader(csvfile) for i, row in enumerate(readata): try:

Re: importing csv data into database

2015-04-23 Thread sum abiut
Hi, could you please help me figure out why i am getting this error i am trying to import data from csv file to model buty i am getting the error: *list index out of range* and if refering to line 20 on view which is: *data.FirstName=row[1]* view.py def readcsvfile(request): with open('/var/ww

Re: importing csv data into database

2015-03-31 Thread sum abiut
Thanks guys, appreciate your help. Yes i am looking to have a form that accepts CSV files. I will have a read on the link that you guys have provided and see how it goes. Cheers On Wed, Apr 1, 2015 at 11:44 AM, Andrew Farrell wrote: > Hello Sum, > > There are two approaches you could take. > O

Re: importing csv data into database

2015-03-31 Thread Andrew Farrell
Hello Sum, There are two approaches you could take. One is to install a plugin like django-import-export and then use it's import functionality. Its been a while since I've done this, but when I did under django-1.4 it Just Worked. This is

Re: importing csv data into database

2015-03-31 Thread James Schneider
Is it a one-time import or are you looking to have a form that accepts CSV files? Either way, I would start with the Python csv module. Works really well and should be able to convert your CSV file to a standard Python list of lists, which you should be able to coerce into models, etc. https://do

importing csv data into database

2015-03-31 Thread sum abiut
Hi, Could someone please advise this i am trying to import data from csv file or write to database but i am confuse on how to start. i am using sqllite database. Cheers, -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this g