# Error with loadTable via drop

**URL:** https://discourse.processing.org/t/error-with-loadtable-via-drop/23092
**Category:** p5.js
**Created:** [August 6, 2020, 8:51pm UTC](https://discourse.processing.org/t/error-with-loadtable-via-drop/23092 "2020-08-06T20:51:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tapestes](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@Tapestes](https://discourse.processing.org/u/Tapestes)
#### Post date: [August 6, 2020, 8:51pm UTC](https://discourse.processing.org/t/error-with-loadtable-via-drop/23092/1 "2020-08-06T20:51:57Z")

</div>

In p5.js (v1.1.9, MacOS 10.15.6), I’m trying to load data into a table via the drop method. File appears to load fine, and when I log to the console I can see the file name and file contents no problem. The issue is loading that file into the a table. The drop examples I found online all show loadTable(file.data… ). But, the errors indicate loadTable wants the file path, which I believe is inaccessible. Here’s some example code. Appreciate any help I can get.

```auto
let dropzone;

function setup() { 
    dropzone = select('#drop_area');
    dropzone.drop(gotFile);
}

function gotFile(file) {
    loadTable(file.data, 'header', print);
}

```

Here’s the errors. Note the “Test,It,OK1,2,3” is the content of the .csv file, and obviously not the path.

```auto
 http://127.0.0.1:63991/Test,It,OK1,2,3 404 (Not Found)
🌸 p5.js says: It looks like there was a problem loading your table file. Try checking if the file path (Test,It,OK
1,2,3
) is correct, hosting the file online, or running a local server.

```

---

<div class="post-metadata">

### Author: ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)
#### Post date: [August 12, 2020, 8:01am UTC](https://discourse.processing.org/t/error-with-loadtable-via-drop/23092/2 "2020-08-12T08:01:50Z")

</div>

[`loadTable`](https://p5js.org/reference/#/p5/loadTable) expects the first argument to be a URL. An address to a file located on a web server somewhere. That’s a problem when, as in your case, the file content is already available in memory.

You could use [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) as a workaround. That’s a smart way to embed small data inside an URL. Imagine a plain text file `hello.txt`:

```auto
Hello World!

```

Represented like a data URL, it looks like this:

```auto
data:text/plain,Hello%2C%20World!

```

Fortunatly for us, `loadTable` happily accepts data URLs. 🎉 A tiny adjustment to `gotFile` should do it:

```auto
function gotFile(file) {
  const dataURL = 'data:text/csv;charset=utf-8,' + encodeURIComponent(file.data);
  loadTable(dataURL, 'csv', 'header', print);
}

```
