Skip to main content
2 of 2
added 304 characters in body
Doc Brown
  • 220.5k
  • 35
  • 410
  • 625

There are virtually dozens of reasons why separating text files from the program which reads and processes them can be beneficial, even if the program is written in a scripting language (so in a text file itself) and both are always deployed together. By separating the text file, you can

  • hand it over to another person who has no knowledge of the scripting language or programming at all and let the person create or maintain the file

  • use a completely different editor (for example, a spreadsheet application), to maintain the text file

  • give the data a version number different from the program

  • let the same, untouched program process different variants of the text file (for example, for testing purposes, or for different, customized instances of the database)

  • reuse the same script to populate different tables in your database easily from different text files, without the need to create a large, unmaintainable BLOB of a >10000 lines script

I guess if you think twice about the question, you can extend this list by a lot of further points by yourself.

Of course, if the task is just to fill one or two tables with two or three columns and rows, and the data virtually never changes, putting everything into one single script maybe sufficient and anything else unnecessary overhead. But if the task gets larger, separation of concerns becomes important.

Doc Brown
  • 220.5k
  • 35
  • 410
  • 625