Import Muliple Text Files In One Folder Location Into One Long CSV
Posted on 2006-11-12
I have 500 or so customer files that are stored in individual text files for each customer. Each customer file contains their orders. I wanted to know if there is a way to import these files (all in one folder) into one big a CSV file for loading into a database.
Each text file in the folder takes the following format.
-The first line of the file is what is associated should be considered the "Customer Number". It is an integer value followed by a colon, ":", and can take the form of a small number like 1 or 2 or a larger number like 503.
-All other lines in the file should be considered order records for the customer indicated at the top of the file. The first item, e.g. 1234 on the second line of the example below, should be considered "Item Number", the second item = "Quantity", and the third item = "date". There are only three elements on each line following the first line (e.g. 1: does not have the normal three items).
In the CSV output I would like to place all the orders with the customer number inserted as the first item in the CSV. Right now, each customer has an individual text file where all their orders are housed. So basically the CSV is going to be one long file that combines all the .txt files in folder X and takes the customer number an transposes it.
Any help would be appreciated, as doing these by hand would take a very long time.