How to write data to a csv file in ionic

Hi everyone…
I have my call logs displayed in a list format with name,phone number and other details…now i want to write all this data to a text file ,convert it into csv format and then export this csv file…

Please help how to achieve this…steps to do this would be helpful …
Thanks.

CSV is a bad format. It’s poorly specified and hard to both write and parse properly. Use JSON instead.

ok…how to do that…

This forum is not a “write my app for me” service. Provide code that you have tried, what you are expecting it to do, and how that differs from what it does.

I have just created a list which reads the call log from the mobile and displays it…I want to store this in a file so that it can be exported…

<ion-list>
    <ion-item *ngFor="let d of mobileId">
      <p>{{d.caller}}</p>
      <p> {{d.type}}</p>
      <p>{{d.date}}</p>
      <p>{{d.phoneNumber}}</p>
    </ion-item>
  </ion-list>

ts file-

 {		
		this.mobileId =JSON.parse(this.device.uuid);
  }

please tell me the steps to achieve this…
code is not required…I want to know the right way to achieve this…

What do you want to do with the file, whatever format it may have?
Your variable names seem strange. If the list is a list of calls, the variable should be calls. Otherwise this is very confusing.

I want to get all the call logs written in a file and want to export this as a csv file…

So you want to put a .csv file on the device.

Okay, 2 steps: 1) Build the file as a “string” in memory first, then 2) write the stuff you have onto the device.

Step 2 is pretty standard, look at https://ionicframework.com/docs/native/file/

For step 1 you have to understand what you actually want to build. What data should be in there? How should it be seperated?
Then you have to find a way to transform the array of data you have into that format. One “naive” way is to loop over the data with for … loop and add to a string at the end. When the string is in the correct format, go on with step 2. (The other non-naive way is to find a library to build a CSV from an array automatically. They probably exist, but you will have to find the right one that works.).

Don’t use Ionic.

Every language has its place. This is not the place for Ionic/Angular/JavaScript. Web technologies are not meant to write or normalize text files.

Time to ask Stack Overflow.