# loadTable in constructor - check data is loaded

**URL:** <https://discourse.processing.org/t/loadtable-in-constructor-check-data-is-loaded/13257>\
**Category:** Coding Questions\
**Created:** [August 8, 2019, 1:12pm UTC](https://discourse.processing.org/t/loadtable-in-constructor-check-data-is-loaded/13257 "2019-08-08T13:12:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gxkendall](https://avatars.discourse-cdn.com/v4/letter/g/e99b99/32.png) [@gxkendall](https://discourse.processing.org/u/gxkendall)\
**Post date:** [August 8, 2019, 1:12pm UTC](https://discourse.processing.org/t/loadtable-in-constructor-check-data-is-loaded/13257/1 "2019-08-08T13:12:21Z")

</div>

I know that you should call loadTable in preload, so that the data will will be loaded before setup is called.

But I want to call loadTable in a constructor, but make sure it is loaded before continuing.

I don’t have ES8 (so can’t use async/await) so I think I have to use a callback? But this can only detect errors in the file (e.g. it can’t find it) - I think?

Can somebody tell me how I handle this?

Thanks

G

---

<div class="post-metadata">

**Author:** ![gxkendall](https://avatars.discourse-cdn.com/v4/letter/g/e99b99/32.png) [@gxkendall](https://discourse.processing.org/u/gxkendall)\
**Post date:** [August 9, 2019, 11:24pm UTC](https://discourse.processing.org/t/loadtable-in-constructor-check-data-is-loaded/13257/2 "2019-08-09T23:24:25Z")

</div>

Managed to work it out:

this.csvData = loadTable(file, ‘csv’, ‘header’,  
function(){print(‘Data loaded okay’)});
