# Custom Component using PHP to read CSV?

**URL:** <https://forums.realmacsoftware.com/t/custom-component-using-php-to-read-csv/44677>\
**Category:** Elements API\
**Created:** [September 18, 2024, 2:56pm UTC](https://forums.realmacsoftware.com/t/custom-component-using-php-to-read-csv/44677 "2024-09-18T14:56:22Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [September 24, 2024, 5:40pm UTC](https://forums.realmacsoftware.com/t/custom-component-using-php-to-read-csv/44677/4 "2024-09-24T17:40:50Z")

</div>

OK, here is the latest now generalised version! 😀

You can download it here: [CSV TABLE EXAMPLE](elementsapp://downloadDocument/o4gRkbwfWPmg)

It can work on csv files external to Elements or using csv files stored in Resources of which examples are included. The advantage of using Resources (at least initially) is that you can test in Preview.

The Custom Element is named **csvTable**.

I have extended the Properties so that you can configure the Separator (default is a comma), Enclosure (default is double quotes) and Escape (default is backslash) for the CSV file.

Additional Properties are available to set options (Text color, Background Color, Border Color, Alignment and Padding) independantly for the Table Header, Table Cells and Error messages (e.g. missing file) for the whole table.

Additionally, you can add items to the **alignments** Collection to override the alignment for specific columns. In the Mac Models example Price has been overridden to be right aligned.

Note: To change the colours of any of the Properties, you have to select a colour from a different theme colour band and then Elements will take note of it the colour you select.

---

_[View the full topic](https://forums.realmacsoftware.com/t/custom-component-using-php-to-read-csv/44677)._
