Please create a simple application with the specifications below. The product should be a basic document generator with template support.
- You are free to choose the language and the technology you are comfortable with.
- You can write a desktop, console or web application.
- The application must use a single template file. The template must not be hard-coded. Example template is given below.
- App must accept a CSV data file from the user. Example below.
- App must read all the lines from the CSV file and parse the data.
- For every line in the data file, app must fill the placeholders in the template file and create a separate document and save it on the disk.
- App must not assume hard-coded folder paths or file names. For these, user input or configuration files are acceptable solutions.
- App should not crash or display unhandled error messages for missing or invalid data. Any errors should be reported to the user in a friendly way.
- App should not have issues with Turkish characters in the template or data (support UTF-8).
- Ideally, user should be able to compile and run the application without making changes to source code.
The template file is the empty text document with placeholders for data fields. An example is given below. This template can be packed along with the source code, but it must not be hard-coded into the program. Any changes to the template should not break the program. This includes changing of fixed text or removal of placeholders.
Konu: {TARIH} tarihli faturanız.
Sayın {AD} {SOYAD}, {FATURANO} numaralı hizmet faturanız ekte gönderilmiştir. Bu dönem için fatura tutarınız: {TUTAR} TL.
Saygılarımızla,
The words in brackets are placeholders. The app must replace these with the data extracted from the data files, except for the {TARIH} field. This field must be filled with the current date.
If there are unrecognized placeholders in the template file, they should be ignored.
The data file contains the field values: One line for each customer. It is a CSV (comma separated value) file saved from Excel:
123456;Ahmet;Cingöz;34
234567;Ali Fuat;Bilge;45
345678;Ayla;Kaplan;19
456789;Süheyla ;Akça Oğul;72
Format of the data file is fixed. Each line contains four fields, separated with semicolons. The fields are FATURANO, AD, SOYAD and TUTAR in order.
Your app should read the data file, merge the fields into the template and create a separate output file for every line. FATURANO must be used for the filename and the extensions must be TXT. For the example above, your app should create four files:
123456.txt
234567.txt
345678.txt
456789.txt
Each output file must contain text merged from the template file. For example, 456789.txt file must contain the following:
Konu: 15.10.2014 tarihli faturanız.
Sayın Süheyla Akça Oğul, 456789 numaralı hizmet faturanız ekte gönderilmiştir. Bu dönem için fatura tutarınız: 72 TL.
Saygılarımızla,
Your app must not assume that data file will contain four lines. App must be able to handle data files with only one line or a hundred lines.
Your app must not crash if the format of the data file is incorrect. Instead, it should try to display appropriate warnings to the user.
- Sample template and data files are provided with this document. These files are saved with UTF-8 encoding.
- Keep in mind that your application will be tested with different templates (with similar format) and data files (both valid and invalid).
- You can use code snippets found on Internet, but you must put reference comments above them, including the source web address. Also, make sure you have a thorough understanding of such code because you may be asked to explain or modify your code for a final evaluation.
- Commented and clean code is always a plus.
- Unexpected compilation or runtime errors are always a minus.
- You can add extra useful features not specified in this document. These too will be considered a plus.