Re: importing csv file into sqlite

2008-12-19 Thread Peter Otten
James Mills wrote: values = ,.join([\%s\ % x for x in line]) print INSERT INTO %s %s VALUES (%s); % (table, fields, values) http://xkcd.com/327/ -- http://mail.python.org/mailman/listinfo/python-list

Re: importing csv file into sqlite

2008-12-19 Thread James Mills
On Fri, Dec 19, 2008 at 8:32 PM, Peter Otten __pete...@web.de wrote: James Mills wrote: values = ,.join([\%s\ % x for x in line]) print INSERT INTO %s %s VALUES (%s); % (table, fields, values) http://xkcd.com/327/ It's a tool! Not one meant to be used publicly from untrusted users. Free

Re: importing csv file into sqlite

2008-12-19 Thread klia
://www.nabble.com/importing-csv-file-into-sqlite-tp21067453p21090356.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: importing csv file into sqlite

2008-12-19 Thread Peter Otten
klia wrote: John Machin wrote: On Dec 18, 6:20 pm, klia alwaseem307s...@yahoo.com wrote: klia wrote: hey guys, i have a hug .csv file which i need to insert it into sqlite database using python. my csv data looks like this Birthday2,12/5/2008,HTC,this is my birthday

Re: importing csv file into sqlite

2008-12-19 Thread John Machin
On Dec 19, 11:17 pm, klia alwaseem307s...@yahoo.com wrote: [ancient screed snipped] hey guys i took all of your suggestion but my goal ain't yet achieved :-(( these are the codes after changes, john i couldn't really catch what do you mean by renaming input, is it just normal renaming.

Re: importing csv file into sqlite

2008-12-19 Thread John Machin
On Dec 18, 5:17 pm, James Mills prolo...@shortcircuit.net.au wrote: def readCSV(file):   if type(file) == str: Stiff cheese if the file path is a unicode object, eh?      fd = open(file, rU)   else:      fd = file -- http://mail.python.org/mailman/listinfo/python-list

Re: importing csv file into sqlite

2008-12-18 Thread Chris Rebert
On Wed, Dec 17, 2008 at 11:20 PM, klia alwaseem307s...@yahoo.com wrote: klia wrote: hey guys, i have a hug .csv file which i need to insert it into sqlite database using python. my csv data looks like this Birthday2,12/5/2008,HTC,this is my birthday Sea,12/3/2008,kodak,sea

Re: importing csv file into sqlite

2008-12-18 Thread James Mills
@klia: You could have had this done hours ago had you taken my suggestion, used my tool and just piped it into sqlite3 on the command line. --JamesMills -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list

Re: importing csv file into sqlite

2008-12-18 Thread Peter Otten
Chris Rebert wrote: klia wrote: for item in input: curse.execute('INSERT INTO photos VALUES (?,?,?,?)',item) I believe you need to change 'item' to '*item' to expand the list in the call so that the function gets 4 additional args rather than 1 additional arg that happens to be a

Re: importing csv file into sqlite

2008-12-18 Thread John Machin
On Dec 18, 6:20 pm, klia alwaseem307s...@yahoo.com wrote: klia wrote: hey guys, i have a hug .csv file which i need to insert it into sqlite database using python. my csv data looks like this Birthday2,12/5/2008,HTC,this is my birthday Sea,12/3/2008,kodak,sea

Re: importing csv file into sqlite

2008-12-18 Thread Gabriel Genellina
En Thu, 18 Dec 2008 04:17:47 -0200, James Mills prolo...@shortcircuit.net.au escribió: How big ? When size is important in data processing, you should _never_ try to load it all up at once. Use filters... But your code does *exactly* that, it reads the whole file in memory: def

Re: importing csv file into sqlite

2008-12-18 Thread James Mills
On Fri, Dec 19, 2008 at 10:11 AM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: But your code does *exactly* that, it reads the whole file in memory: def mkBuffer(fd): buffer = StringIO() buffer.write(fd.read()) ... That mkBuffer function has no useful purpose IMHO, just remove it.

importing csv file into sqlite

2008-12-17 Thread klia
codes. thanks in advance -- View this message in context: http://www.nabble.com/importing-csv-file-into-sqlite-tp21067453p21067453.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: importing csv file into sqlite

2008-12-17 Thread Chris Rebert
On Wed, Dec 17, 2008 at 9:58 PM, klia alwaseem307s...@yahoo.com wrote: hey guys, i have a hug .csv file which i need to insert it into sqlite database using python. my csv data looks like this Birthday2,12/5/2008,HTC,this is my birthday Sea,12/3/2008,kodak,sea

Re: importing csv file into sqlite

2008-12-17 Thread James Mills
On Thu, Dec 18, 2008 at 3:58 PM, klia alwaseem307s...@yahoo.com wrote: hey guys, i have a hug .csv file which i need to insert it into sqlite database using python. my csv data looks like this Birthday2,12/5/2008,HTC,this is my birthday Sea,12/3/2008,kodak,sea

Re: importing csv file into sqlite

2008-12-17 Thread klia
this message in context: http://www.nabble.com/importing-csv-file-into-sqlite-tp21067453p21068111.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list