# Save data to local csv

**URL:** <https://community.thunkable.com/t/save-data-to-local-csv/162899>\
**Category:** Questions about Thunkable X\
**Created:** [July 31, 2019, 3:39am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899 "2019-07-31T03:39:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![myusername](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@myusername](https://community.thunkable.com/u/myusername)\
**Post date:** [July 31, 2019, 3:39am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/1 "2019-07-31T03:39:32Z")

</div>

Hi, I’ve done my best to search for an answer so apologies if this has been covered elsewhere.

The app has some text inputs, location data, and Bluetooth LE data.

When all fields are completed, i’d like the user to be able to generate a csv file that is saved on their phone that records the data that was entered. The data doesn’t need to persist between sessions in the app. Is this possible and if so what’s the best way to go about it?

---

<div class="post-metadata">

**Author:** ![renren66](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@renren66](https://community.thunkable.com/u/renren66)\
**Post date:** [July 31, 2019, 3:48am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/2 "2019-07-31T03:48:54Z")

</div>

So do you want to export the csv file or simply display a spreadsheet with the data?

---

<div class="post-metadata">

**Author:** ![renren66](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@renren66](https://community.thunkable.com/u/renren66)\
**Post date:** [July 31, 2019, 3:58am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/3 "2019-07-31T03:58:07Z")

</div>

You can use a web viewer displaying a Google Sheet with the Google Sheets API to update the data.

---

<div class="post-metadata">

**Author:** ![renren66](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@renren66](https://community.thunkable.com/u/renren66)\
**Post date:** [July 31, 2019, 4:00am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/4 "2019-07-31T04:00:39Z")

</div>

Or you can just display an Airtable spreadsheet with the web viewer and update the data with blocks.

---

<div class="post-metadata">

**Author:** ![myusername](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@myusername](https://community.thunkable.com/u/myusername)\
**Post date:** [July 31, 2019, 4:19am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/5 "2019-07-31T04:19:20Z")

</div>

Yes, I’d like to export the csv file

---

<div class="post-metadata">

**Author:** ![renren66](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@renren66](https://community.thunkable.com/u/renren66)\
**Post date:** [July 31, 2019, 6:25am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/6 "2019-07-31T06:25:50Z")

</div>

[https://json-csv.com/api](https://json-csv.com/api)  
Perhaps this API will help you out.

---

<div class="post-metadata">

**Author:** ![myusername](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@myusername](https://community.thunkable.com/u/myusername)\
**Post date:** [August 4, 2019, 6:05am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/7 "2019-08-04T06:05:58Z")

</div>

Thanks renren66 I’ll check it out.

So there’s no way to build and save a file (csv, txt, pdf etc) locally+offline at this stage in X?

---

<div class="post-metadata">

**Author:** ![dlmetzgerbcch](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dlmetzgerbcch](https://community.thunkable.com/u/dlmetzgerbcch)\
**Post date:** [January 20, 2020, 4:25am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/8 "2020-01-20T04:25:13Z")

</div>

I’m interested in the same thing. Has anyone used the above [https://json-csv.com/api](https://json-csv.com/api) successfully? Or figured how to create a shareable CSV? Any chance you’d share your blocks?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [January 20, 2020, 11:01am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/9 "2020-01-20T11:01:11Z")

</div>

![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/5/4563c6712a284615527e1046c187f7431a3ddfb0.png)

---

<div class="post-metadata">

**Author:** ![dlmetzgerbcch](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dlmetzgerbcch](https://community.thunkable.com/u/dlmetzgerbcch)\
**Post date:** [January 20, 2020, 5:14pm UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/10 "2020-01-20T17:14:40Z")

</div>

Thanks very much, I’ll try that.

---

<div class="post-metadata">

**Author:** ![dlmetzgerbcch](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dlmetzgerbcch](https://community.thunkable.com/u/dlmetzgerbcch)\
**Post date:** [January 21, 2020, 4:20am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/11 "2020-01-21T04:20:41Z")

</div>

Thanks, I got the connection to work, but I don;t see how I can get a CSV file back? Only the same text that I send?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [January 21, 2020, 9:05am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/12 "2020-01-21T09:05:58Z")

</div>

I showed you an example of working with the API. I didn’t see an example of working with files there.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 21, 2020, 3:41pm UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/13 "2020-01-21T15:41:16Z")

</div>

I looked through the info for that API and a few others like it and I didn’t find anything that will return a CSV file that looks useable with Thunkable. They are almost all online generators that don’t have APIs associated. And the ones with APIs don’t seem to return files. ☹

---

<div class="post-metadata">

**Author:** ![dlmetzgerbcch](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dlmetzgerbcch](https://community.thunkable.com/u/dlmetzgerbcch)\
**Post date:** [January 22, 2020, 6:06am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/14 "2020-01-22T06:06:38Z")

</div>

Thanks so much for checking! Too bad there is no good solution for this at this time.

---

<div class="post-metadata">

**Author:** ![Christian\_Sigge](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/christian_sigge/32/27756_2.png) [@Christian\_Sigge](https://community.thunkable.com/u/Christian_Sigge)\
**Post date:** [August 27, 2020, 10:20am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/15 "2020-08-27T10:20:02Z")

</div>

Hello, just want to ask, did you found a solution to export data?

Im looking aswell for a way to export data from a local database, I would create a json but i just still don’t know how to send it out of the app. Paid APIs are not an option for me.

Anyone?

---

<div class="post-metadata">

**Author:** ![tbcguytb](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@tbcguytb](https://community.thunkable.com/u/tbcguytb)\
**Post date:** [March 16, 2021, 11:14pm UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/16 "2021-03-16T23:14:46Z")

</div>

Did you ever figure out a solution to this. I am looking at this 8 months later and still see no viable solution. I have an app that the user stores load information and would like the ability for them to email the loads to their superiors. If not the only way i can see this working is to use firebase and then return some json and maybe with blocks code create some sort of email response.

---

<div class="post-metadata">

**Author:** ![cneskey](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cneskey/32/96926_2.png) [@cneskey](https://community.thunkable.com/u/cneskey)\
**Post date:** [March 17, 2021, 12:17am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/17 "2021-03-17T00:17:19Z")

</div>

I haven’t figured out a clever way of saving files to the phone’s file system using Thunkable but I did manage to configure it to send the comma separated values in the form of the body of an email.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/5/35916b860634ee715d6ad1715d4ed2fe51d68fec.png)

At some point I want to try replicating this in Thunkable using the open-ended functions or by simply editing the exported APK in android studio and adding this:

> <https://stackoverflow.com/questions/27772011/how-to-export-data-to-csv-file-in-android>

AHEM, MAYBE THUNKABLE FOLK ADD A MODULE FOR US INSTEAD… HINT HINT.

```auto
  String baseDir = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
  String fileName = "AnalysisData.csv";
  String filePath = baseDir + File.separator + fileName;
  File f = new File(filePath);
  CSVWriter writer;

  // File exist
  if(f.exists()&&!f.isDirectory())
    {
      mFileWriter = new FileWriter(filePath, true);
      writer = new CSVWriter(mFileWriter);
    }
  else
    {
      writer = new CSVWriter(new FileWriter(filePath));
    }

    String[] data = {"Ship Name", "Scientist Name", "...", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").formatter.format(date)});

  writer.writeNext(data);

  writer.close();

```

---

<div class="post-metadata">

**Author:** ![tbcguytb](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@tbcguytb](https://community.thunkable.com/u/tbcguytb)\
**Post date:** [March 18, 2021, 2:48am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/18 "2021-03-18T02:48:51Z")

</div>

I tried the blocks above…works but, not so well with 7 or 8 columns. CSV is exported like the image but does not convert to excel very well. what we need is the ability to do this.  
 ![Capture](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/b/3b9d0d5810097c8ee3eb5e9c4522a34db8596666.png) . This is from [https://onlinecsvtools.com/](https://onlinecsvtools.com/) they might have an api

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 18, 2021, 5:11am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/19 "2021-03-18T05:11:49Z")

</div>

Use Google sheet as your database and create a macro in the sheet to export to CSV.

---

<div class="post-metadata">

**Author:** ![tbcguytb](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@tbcguytb](https://community.thunkable.com/u/tbcguytb)\
**Post date:** [March 18, 2021, 11:41am UTC](https://community.thunkable.com/t/save-data-to-local-csv/162899/20 "2021-03-18T11:41:44Z")

</div>

Initially, that is where I was headed. But, found out that any Google sheet has a 100 user limit. That doesn’t allow for scalability. The app will have users…more than 100 hopefully 🙂 the firebase route is the obvious route, but I am not to versed in converting Json to a readable format. The users record load info. At anytime they need the ability to send one or more of these records to someone higher up…preferably in a readable format.

[Next page](https://community.thunkable.com/t/save-data-to-local-csv/162899.md?page=2)
