Topic: CSV to HTML
Totage's photo
Thu 01/06/11 01:00 PM
I'm downloading a large CSV file. I want to convert it into an HTML file, but I then want to break it up into smaller HTML files. The CSV file is about 36.4MB, when I open it and save as .html in OpenOffice, it more than doubles it's size and will not open in my browser.

Is there a better/faster way of doing this?

Tessa02's photo
Thu 01/06/11 01:10 PM
I've worked some with html but not with the csv files. Not sure if this code will help.

http://www.codeave.com/asp/code.asp?u_log=101

fobroth's photo
Thu 01/06/11 01:20 PM
Hi totage,

Until someone more knowlegeable shows up, I looked on google and it looks like other people are doing it with various tools.
Not sure what platform you use but I looked in my package manager and one of the tools that came up for linux was gnumeric. (it'll export to html)
Hope it's a start.

Totage's photo
Thu 01/06/11 02:41 PM

Hi totage,

Until someone more knowlegeable shows up, I looked on google and it looks like other people are doing it with various tools.
Not sure what platform you use but I looked in my package manager and one of the tools that came up for linux was gnumeric. (it'll export to html)
Hope it's a start.



Thanks, that sounds like it may work. OpenOffice was crashing when I would try to export as XHTML, but I was able to save as html. That might be the whole problem. I'll give gnumeric a try and see if it works.

The main problem is the size though. I need the HTML to be in files that are 500KB and smaller, but the HTML file I have now is over 66MB.

Totage's photo
Thu 01/06/11 05:55 PM
I found a flat file PHP search script! I may not have to mess with the CSV file after all, hopefully just upload it, maybe break it into smaller files, but it should work for now.

fobroth's photo
Thu 01/06/11 10:59 PM
Hey Tessa02,
I looked at the link you listed and I bet that's exactly what he's needing to open his csv in a browser. Good stuff.

Totage's photo
Fri 01/07/11 06:57 AM
Actually I don't even want the CSV, it's just a work around for another issue I'm having. I was hoping it would make things easier, turns out it's just complicating things for me, lol.

Totage's photo
Fri 01/07/11 12:25 PM
Actually, I need to open the CSV OFFLINE to manually extract info. from to add to a MYSQL database. OpenOffice.org is working fine for that now. I'll just have to suck it and do a lot of hard work I don't want to do. lol

I got a nice little tutorial to write a simple PHP+SQL search engine, so I'm going to take the data I need from the CSV and put it the SQL DB I just created.

I was trying to get a product data feed to work on my website, but for some reason it wouldn't work. So, I figure the best solution is to just make a database and search engine, then just go from there.

no photo
Mon 01/17/11 03:36 AM

I'm downloading a large CSV file. I want to convert it into an HTML file, but I then want to break it up into smaller HTML files. The CSV file is about 36.4MB, when I open it and save as .html in OpenOffice, it more than doubles it's size and will not open in my browser.

Is there a better/faster way of doing this?


It looks like your thought process has developed a fair amount since this initial post; but addressing this question above, only:

I would break the huge CSV file into multiple CSV files, *then* convert them to html files. The linux 'split' command does this based on number of bytes into the file, but you might prefer splitting on 'number of lines'. I don't know the smart way to do that off the top of my head, but one inefficient way might be to shell script something using 'head' and 'tail' to lop of sections of the file iteratively.

The batch the conversion to html, and batch the file transfer.