Appending data to a CSV file

Hi,
I’m new to this forum, so, hello everyone!

There is something I need to achieve but I am not sure how to do it.

We are a small hotel/b&B. We use a property management system to manage our bookings in house, the problem is that some of the reports it produces are very basic. There is an export feature that produces a csv file based on date criteria. I have no control on the export criteria other than that. I cant rename the file during export or where it is saved, there is now dialogue in-between hitting the export button and the file being saved.

What I would like to be able to do is to have a script which recognises the naming convention of the exported file and automatically appends new file data to a different CSV file, so i can then set up a recurring import into Filemaker and do what what I need to do with it.

I see it as 3 different areas:

  1. Monitor a folder for changes
  2. Identify the right file name
  3. Append the file, there will need to be a check for duplicates somewhere, I think I could do this in Filemaker

If anyone has any suggestions it would be appreciated. I have done a bit of scripting, I understand the basics but I’m still at the lower end of the learning curve.

Thanks for any help.

Model: Mac mini
AppleScript: 2.2.4
Browser: Safari 536.30.1
Operating System: Mac OS X (10.8)

Hi Niknik,

Can you post a small example of your file? I think there are several different types of csv files.

Edited: I think you should add more specifics.

Like, what is the naming convention? What are the fields? Is the naming convention part of the record?

gl,
kel

Hi Niknik,

  1. You can monitor a folder two ways. Firstly, with a folder action, but there are some limitations. Secondly, you can create an application that monitors the folder.
  2. You can identify a file by its name if you know what folder it is in.
  3. You can append one file to another, but I don’t know what you mean by “check for duplicates”.

gl,
kel

Hi kel,
Thanks for taking the time to respond. I can only post the headings as the file contains private customer information. But it is all separated by commas, there are 42 columns i’m not sure how the end of file is indicated though.

I have played with the Folder Action for monitoring changes within the folder, it seems to work but is a bit unstable but that could be my scripting.

The files are named data.csv, if the file is not removed the next file in the folder ail be called data-1.csv.

When these files are produced there could be duplicate information contained within them. So i was wondering if the duplicates could be removed during the appending process but I think it might be easier to do it in the import into Filemaker.