EXCEL to SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bwv2
Forum Commoner
Posts: 83
Joined: Fri Jun 10, 2005 11:50 am
Location: AZ

EXCEL to SQL

Post by bwv2 »

I have a very large (3.5 GB) EXCEL spreadsheet that I need to use in my website, but it's too large to open and causes my computer to crash. I want to convert it to SQL so that the file size is lowered and will use less space on the server.

Anyone know how to import .xls into an SQL database without opening the excel file?
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

save the file as tab delimited .txt and make a function to read it in , it will use alot of power and such but you only need to do it once.
bwv2
Forum Commoner
Posts: 83
Joined: Fri Jun 10, 2005 11:50 am
Location: AZ

easier said than done...

Post by bwv2 »

Opening the file and saving it as a .txt file would work, except I encounter some problems in the file size. Excel will only support up to 65,536 rows in a spreadsheet. Mine has many many more rows, so when I open the file, it won't load the file completely.

If it helps, my file is a .csv file already (comma separated values), not a .xls file like normal excel worksheets. I tried opening the file with notepad, but got an error saying the file was too big for it. I tried wordpad, but it also had an error. What I need is some sort of script in some language that will read my comma separated file and write to a tab delimited file. Then I could load it into an SQL sheet.

Anyone know how to write a script that would read my .csv and write it as .txt? I seem to remember something like that from c++, but can't remember it. Any help would be great. Thanks.
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Post by froth »

Well csv is plaintext so just get_file_contents, explode, and parse into sql...
Post Reply