How to merge several csv files into one

2017-08-29

This article aims to provide the insight into how to use FastReport.Net to merge two logically related CSV files into one.  Storing data in CSV files is often very convenient. You can always open such files by any text editor and tweak them. But what if in one document there are references to data from the other document? You have to merge two files into one, for further convenient work with the CSV document. It can be done manually, which is rather time - consuming, or you can use Excel, that requires some knowledge of the macros. The third way is the most easy-to-handle - to use FastReport.

So, we have two CSV files. One contains a list of orders, the second one - a list of customers. We need to display the customers' names and phone numbers for each order. The Orders table has a foreign key "CustNo' to the Customers table. In turn, the Customers table has the primary "CustNo" key. As you understand, we will link the two tables to this field.

Create a new report in the designer. Add a new data source -  a CSV file:

One more data source is the second file.

As a result, we get two connections:

 

Now we need to link two tables. To do this, click the drop-down menu "Actions" and select "New relation".

 

We select the main table, for example "Orders". The subordinate table is "Customers". For both tables we define the key fields. In our case, in both tables the keys are called "CustNo":

 

Now look at the window "Data":

 

For the Customers table now there is an associated table "Orders".

We place the Company field in the Customers table on the Data band. We also place all fields there, except the CustNo fields, which are from the linked table " Orders". As there are a lot of fields, they do not fit on the report page. Open the page settings in the top toolbar "Report":

 

On the "Other" tab we set properties: Extra design width, unlimited height, unlimited width. The last two properties allow you to expand your report page to the required size in the report view mode.

Before exporting the report to a CSV file, let us consider some useful tips on formatting. To prevent the addition of blank lines and columns in the export, try to place the margins on your page close to each other. For the header of the data, we reduce the height to a minimum:

Now run the report in preview mode.

 

Click "Save" and choose "CSV file...". Now agree with the default export settings and set the location of the file saving. As a result, we have a CSV file with information about orders and the company name instead of the CustNo identifier.

 

Using the introduced way, you can merge as many tables as you need from different CSV files, which is really time - saving. Creation of a merged file takes about 10 minutes.

.NET .NET FastReport FastReport Desktop Desktop CSV CSV
10. Juli 2026

Wie konfiguriert man eine Content Security Policy für FastReport .NET WEB-Berichte

Lernen Sie, wie Sie die Content Security Policy für FastReport .NET WEB-Berichte konfigurieren: eine Übersicht über CSP-Direktiven und -Werte, Änderungen in der FastReport-Architektur, typische Umgehungsszenarien und Möglichkeiten, sich davor zu schützen.
22. Juni 2026

So konfigurieren Sie einen Bericht mit Business Objects im Code und im FastReport .NET Designer

In diesem Artikel wird anhand eines praxisnahen Beispiels gezeigt, wie Sie eine .frx-Berichtsvorlage erstellen und verwenden, die mit hierarchischen Business Objects in FastReport .NET herzustellen.
20. Mai 2026

Detaillierter Überblick über die Funktionen der FastGrid-Bibliothek

Ein Überblick über die FastGrid-Bibliothek für VCL und Lazarus: Datenvisualisierung, -bearbeitung und -Strukturierung. Sortieren, Filtern, Gruppieren, komfortable Dateneditoren — alles in einem Artikel!

© 1998-2026 Fast Reports Inc.