Question:
I a general sense, into what exactly do I need to abstract a .CSV file to “run SQL statements” on it?
I think I can write the iteration loop for step 1 of "Problem" below, but I don’t have the slightest idea how to do step 2.
Problem:
I work in university office where an overnight script (that I didn't write) combs the university's database and generates .csv files for letters that I need to send via "mail merge" the following day. It saves these .csv files to a server folder to which I have access.
The technology that does this is limited, and it produces a different .csv file for each admission term. (This seems to be connected to how the automation software knows which admission terms to pay attention to when it combs the university's database.)
However, my MS Word Mail Merge documents don't need this separation of .csv files, as "admission term" is also a field in the .csv file itself. Any variation I need can be done with conditional logic and field insertion.
The separation of .csv files was making me maintain multiple redundant Word documents for the same general idea, just one per term. Headache to maintain every time we transitioned to focusing on a new set of semesters. I fixed that with an Access solution (see below), but now IT is a headache to maintain.
Unfortunately, I don't have access to change the output of the overnight script, so I'm stuck with the .csv files I've got.
What I would like to do is write a program that lives on my desktop PC or on our server and:
- loops through every file in the applicable server folder, determining if it meets certain filename criteria and has non-null contents
- abstracts the .csv files that match step 1 into some abstraction on which SQL can be performed
- performs a SQL “UNION ALL” statement on “SELECT * FROM [the abstraction of the .csv file]” for every matching .csv file
- writes the results of step 3 as a new “merged” .csv file to our server (to which I’ll point Mail Merge files).
- (Plus I’d like to automate my program to execute on a certain schedule, so that will impact my tool choice.)
So far, I've used MS Access to do steps 3 & 4 (and then I have Word read straight from the .mdb file when a Mail Merge file is opened).
However, it’s a real headache when we want to focus on a different set of terms. I have to manually change which .csv files the .mdb looks at because the .csv files I get have admission term built into their filenames.
Every 6 months, I take several hours to import specific new .csv files into new “linked tables,” repoint the unions, clean up old “linked tables” I no longer need, etc.
I’d much rather put a computer to work on the task, even if it has to do it every day. :-)