# CSV file processing

As OS Open Names data is supplied in separate CSV files labelled by two-digit grid references, the files require processing before you can load them into a GIS.

## Moving the header CSV file <a href="#id-3.1-moving-the-header-csv-file" id="id-3.1-moving-the-header-csv-file"></a>

The first step is to combine the individual CSV files with the header CSV file available on the [OS Open Names download page](https://docs.os.uk/os-downloads/products/addresses-and-names-portfolio/os-open-names/os-open-names-downloads). To move and rename the header CSV file:

1. Extract *opname\_csv\_gb.zip* to a folder on your computer.
2. Open the Doc folder and either move or copy *OS\_Open\_Names\_Header.csv* into the Data folder.
3. Rename *OS\_Open\_Names\_Header.csv* to *a\_OS\_Open\_Names\_Header.csv*.

*Adding the “a\_” prefix ensures that the files will be merged in the correct order. The header file will be added first in the output file as it is now at the top of the file list.*

<figure><img src="https://1897589978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcNpJpLP8RROUaWVQo5ea%2Fuploads%2Fx6cDamTFkPW329spAhHR%2F2.jpeg?alt=media" alt="Screenshot in Windows Explorer showing renamed header CSV file (a_OS_Open_Names_Header.csv) displayed at the top of the file list." width="246"><figcaption><p>Screenshot in Windows Explorer showing renamed header CSV displayed at the top of the file list.</p></figcaption></figure>

## Combining multiple CSV files <a href="#id-3.2-combining-multiple-csv-files" id="id-3.2-combining-multiple-csv-files"></a>

This section contains an example of one way to combine the individual CSV files into a single file using a batch (.bat) file.

{% hint style="info" %}
*The combined CSV file will be approximately 1.7Gb with about 2.9 million records. If opened in Microsoft Excel, only the first million records can be seen as the software cannot display more than this.*
{% endhint %}

To combine the CSV files using a batch function:

1. Copy the following text and paste it into a new Notepad file: *copy \*.csv outputfile.csv*.
2. Save the Notepad file with the .bat file extension (for example, *combine\_csv.bat*) in the Data folder that contains the 819 CSV files.
3. Close the .bat file, navigate to the Data folder and double click on the batch (.bat) file that you saved in the previous step.

*A MS-DOS window will open automatically and then close when the process is complete.*

4. A new CSV file named *outputfile.csv* will display in the Data folder. You can now delete the other CSV files if you like.

*outputfile.csv contains the content previously in the 819 individual CSV files that was copied over during the batch file process.*

<figure><img src="https://1897589978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcNpJpLP8RROUaWVQo5ea%2Fuploads%2FJQxAo7yoPTgN5GFGPMAy%2F3.png?alt=media" alt="Screenshot in Windows Explorer showing outputfile.csv and combine_csv.bat."><figcaption><p>Screenshot in Windows Explorer showing <em>outputfile.csv</em> and <em>combine_csv.bat</em></p></figcaption></figure>

You will now have an output file that is ready to be used in a GIS application or database.&#x20;

{% hint style="danger" %}
*outputfile.csv might be too large to be opened in a text editor such as Excel.*
{% endhint %}
