How to Run a Nightly CSV Clean-up from the Command Line

How to Run a Nightly CSV Clean-up from the Command Line - Rons Data Stream


Some data arrives on a schedule: a nightly export from an online shop, a daily report from a supplier, log files every hour. If the same clean-up has to happen each time, nobody should have to open an application and click a button at midnight.

Rons Data Stream can run a saved Job from the command line, so a batch file and Windows Task Scheduler can run it for you. This guide shows how to set that up.

Before You Start

You need a Job that already works when you run it in the application. If you don't have one yet, start with How to Clean and Convert Many CSV Files at Once.

Three settings make a Job ready for unattended runs:

  • Relative paths. Save the Job in or next to the data folder. Source and output paths can then be relative to the Job file (. is the Job's own folder), so the Job keeps working if the folder is moved or copied to another computer.
  • A separate output folder. Write the results to a different folder from the source, so the original files are never overwritten.
  • A log file. Add an Output Logger under Output Loggers and give it an Output Container (a folder). After each run, the log tells you what was processed and whether anything failed.

Step 1 – Find the Command for Your Job

The exact command to run a saved Job, and the options it accepts, are described in the help window inside Rons Data Stream. Open it from the application and note the command for running a Job file. Jobs can also use command line variables, so one Job can serve several folders; the help window explains how to pass them.

Test the command once in a Command Prompt and check the output folder and the log file.

Step 2 – Put It in a Batch File

Create a text file called nightly-clean-up.bat next to the Job and paste the command from Step 1 into it, using the full path of your Job file. Double-click the batch file to test it, then check the output folder and the log file again.

Step 3 – Schedule It with Windows Task Scheduler

  1. Open Task Scheduler from the Start menu and click Create Basic Task.
  2. Give it a name, for example "Nightly CSV clean-up", and choose Daily.
  3. Pick a time after the new files usually arrive.
  4. Choose Start a program and browse to your nightly-clean-up.bat file.
  5. In Start in, enter the folder that holds the Job, so relative paths work.
  6. Finish, then right-click the task and choose Run to test it once.

Things to Know

  • Internet connection. A scheduled run checks the licence in the same way as a run you start yourself: Rons Data Stream needs an internet connection from time to time for its licence check, and stops if it cannot connect. Make sure the computer that runs the task can reach the internet. Your data is not sent anywhere except the destinations you set in the Job.
  • Lite or Pro. Rons Data Stream Lite also runs from the command line and processes up to 3 files per run, which is enough to test your batch file and schedule. For real nightly batches you need Rons Data Stream Pro, a one-time purchase of about US$30 with no file limit.
  • Check the log. A scheduled task that fails quietly is worse than no task. Look at the log file regularly, and after any change to the source files' layout.
  • Change the Cleaner, not the task. When the incoming files change, open the Job, update the Cleaner, check the result in the Data Builder, and save. The scheduled task picks up the new version on its next run.

See Also