Importing a large .csv into Excel, -


i trying import large .csv file excel. file has close 4 million rows , 329 columns far exceeded excel's 65536 1m row limit. found vb script online import text files excel once row limit exceeded script create new worksheet till total rows in worksheets equals total rows in original text file.

sub importlargefile() 'imports text file excel workbook using ado. 'if number of records exceeds 65536 splits on more 1 sheet.  dim strfilepath string, strfilename string, strfullpath string dim lngcounter long dim oconn object, ors object, ofsobj object  'get text file name strfullpath = application.getopenfilename("text files (*.csv),*.csv", , "please select text file...")  if strfullpath = "false" exit sub  'user pressed cancel on open file dialog  'this gives full path name e.g. c:\temp\folder\file.txt 'we need split path , file name set ofsobj = createobject("scripting.filesystemobject")  strfilepath = ofsobj.getfile(strfullpath).parentfolder.path strfilename = ofsobj.getfile(strfullpath).name   'open ado connection folder specified set oconn = createobject("adodb.connection") oconn.open "provider=microsoft.jet.oledb.4.0;" & _            "data source=" & strfilepath & ";" & _            "extended properties=""text;hdr=yes;fmt=delimited"""  set ors = createobject("adodb.recordset")  'now open text file , import excel ors.open "select * " & strfilename, oconn, 3, 1, 1 while not ors.eof     sheets.add     activesheet.range("a1").copyfromrecordset ors, 65536 wend  ors.close oconn.close  end sub 

however when run in excel 2007 following error:

run-time error '-2147217900 (80040e14)':  syntax error in clause. 

on clicking debug points line

    ors.open "select * " & strfilename, oconn, 3, 1, 1 

i have non existent vb skills here appreciated.

thanks !

edit: found http://support.microsoft.com/kb/193514 doesn't work in case, in fact not sure place square brackets. place put brackets in line, excel refuses give me run option.

edit 2: tried running on different machine has lot more juice in make memory not issue. computer has office 2013 on (no office 365 though). ran same macro on , it gave following error.

run-time error '3706': provider cannot found. may not installed. 

when click debug points line

oconn.open "provider=microsoft.jet.oledb.4.0;" & _        "data source=" & strfilepath & ";" & _ ->     "extended properties=""text;hdr=yes;fmt=delimited""" 

excel 2007 has no 65k limit, far know. try importing csv directly.

edit: comments tell has 1m limit, there need in splitting file. when simple (no quoted text linebreaks), split , head help. availiable under windows too.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -