I have 1800+ CSV contact files that I must convert to HTML files in Excel. The orginal source files vary widely in length and structure, but I have been able to structure them using TextWrangler and a few other programs.
To date, only by using Excel’s conversion engine can I automatically get the superior consistency and error-tolerance I need to process what are poorly-formed and inconsistent CSV files into well-formed HTML output. With it, I can then will run each file through a really nifty program called Anthracite by Metafy in order to export the tables into arrays. These arrays will then import into Filemaker or some other database for final normalization. A better technical person than I could find a better way to do this, but I know this will work if I can
But of course I have hit the limit of operator knowledge. I’m an analyst, not a programmer. I’ve been working on this stuff for weeks.The learning curve has been steep, not the least of which is due to the fact I’ve had to use a bunch of different new tools to get to where I’m at now. Upstream there was a bunch of preprocessing that had to happen just to convert my old files into this format and get rid of the unnecessary tags and other information, but that’s another story. There may be other ways to do this, but I am focused on doing it this way, and have invested huge hours to get it 95% done. It’s the final 5% that’s killing me.
I have cobbled together a little Applescript that will automate the process of opening the CSV file in Excel 2004, then converting and saving it as an HTML file. It works beautifully, as simple as it is. However, the AppleScript as written will only convert one file at a time. I need a way to have this script loop through the chosen directory, choose each successive file, convert it, and go back to the next in line in the same folder. I’m sure its a simple fix, but I can’t find any reference or example to help me chunk through this directory one file at a time. I’ve been scouring for reference for this but just can’t fnd it.
Here’s the entirety of my script, to date. I hope those knowledgeable folks out there will understand just getting to this point is harder than it looks for a non-scripter like me. And in fact, I got this far only by scouring news groups and picking up tips here and code left there by extremely talented and generous people whose prior work allowed me to finally write this script for Excel 2004 using OS X 10.4.7:
set the_file to “Users:mynameesktop:TESTfolder:Uniquecontactdata 1.csv”
tell application “Microsoft Excel”
activate
open the_file
save active workbook in the_file & “_new.html” as HTML
close active workbook without saving
end tell
I need to revise the AppleScript in order to have it run through, alter, re-name and save-as all the files to HTML.
It may be important to note that I have 1800+files, sequentially numbered “1.csv” through “2200.csv”. Because there are numbers missing from this sequence, my gut tells me I also need some type of “auto skip if file not present” function and/or auto error-handling.
Can anyone help me in this quest? Any help of any sort would greatfully appreciated.
Thanks !