Export Rich Text Field as Markdown

For the rich text field, it would be nice to maintain its formatting when you export it as a CSV. On a similar note, if you integrate airtable with Zapier, it would be great if these rich text fields maintained their formatting when sent to another application, such as Google Docs.

6 Likes

Any update/response on this @Airtable_Admin? it’s great that we can use rich formatting / markdown in Airtable, but if there’s no easy way to get it out of Airtable while preserving that formatting, what’s the point? Is there another way?

I like the idea of preserving the markdown formatting when exporting to CSV. maybe make it an optional flag on either the data field or as a global variable for the export feature. or just a second export option as “Export CSV w/Markdown”.

No updates yet. Eagerly awaiting this feature.

@Airtable_Admin

Would really love an update on this as well – Absolutely loving the feature!

Frankly, it’s misleading to release RTF and not make it abundantly clear that the text can’t be moved or manipulated easily.

I’ve now written several draft for articles with over 4000 words in these fields (and relied heavily on nested bullet points to organize myself).

I’m now faced with the task of manually recreating every line of formatting in google docs…which is a complete waste of time and energy.

RTF’s current design is obviously intended for simpler uses and that’s okay – Had I known this was the case I would never had relied on it to generate something so complex.

@Airtable_Admin Please help so other users don’t fall into this trap of poor user experience.

Thank you :slight_smile:

1 Like

Agree. I have continued to use the rich text fields with the HOPE that a release will come available that will allow exporting to a different medium like google docs.

How do you envision the export of RTF working?

  • what program/app do you want to export to?
  • or do you want to export as individual rich text files?
  • do you want each rich text field within a record to have its own rich text file? That is, if you select several records for bulk export, would a separate rich text file be generated for each record? Or do you want to bulk export records such that they are all in one file, lined up? This gets complicated if one record has multiple rich fields?

I bring these questions up so that we can generate a productive discussion b/c I’m sure these are the challenges that the developers are facing. It may help if we provide guidance.

@Oliver_Lubin, @Sal_Ohcin, @Adrian_Head

This hasn’t been the case for quite some time as rich text markers are included in fields accessed via the API and with the Script block. For example… this field:

image

Is fully tagged when accessed by a script block:

image

With this capability, it’s short hop to an export utility (written in Script Block) that creates pretty much any interpretation that you’d like to create for rich text markers.

2 Likes

Thanks @Bill.French !

Can you point me in the direction of a script somewhere I could use as a template to generate the CSV and add it to an attachment field?

I’m not able to find one online :cry:

I will - slammed at the moment - stay tuned.

No worries - the time is much appreciated :pray:t5:

Okay - here’s a very raw script that demonstrates the process of exporting from a table into a CSV file, uploading the file to DropBox, and then using that host as the staging to upload as an attachment into a different table. It is the quick and very dirty version of a concept that almost everyone could improve with very little effort.

You’ll need a Dropbox account and a Dropbox App (with app token) configured in your Dropbox account profile.

This code uses a simple table of sales data and another table to upload the attachment to an existing record.

CSV Test (table)
image

CSV Files (table)
image

/*
   ***********************************************************
   Airdrop - Export CSV
   ***********************************************************
*/

// display app title
output.markdown('# Export to CSV');

// set the table name
let sourceTableName = "CSV Test";

// identify the fields to be exported
let aFieldList = ["Order #","Ship Date","Invoice"];

// get the source data
let sourceTable = base.getTable(sourceTableName);

// get the data set for 2018/2019
let result = await sourceTable.selectRecordsAsync();

// set a counter for testing
let count = 0;

// iterate across all the records
let csvFile = "";
let csvRow  = "";
let csvItemCount = 0;
for (let record of result.records)
{
    // build the current csv row
    csvRow = "";
    for (var i in aFieldList)
    {
        csvRow += record.getCellValueAsString(aFieldList[i]) + ((i < aFieldList.length - 1) ? "," : "");
    }

    // add the row to the file
    csvFile += csvRow + "\r\n";
    csvItemCount += 1;

    // increment the row counter
    count += 1;

    // break if testing
    if (count > 100)
      break;
}

// display the contents of the csv file
output.inspect(csvFile);

//
// write the csv to a cloud drive service
//

// set the endpoint and app token
let dropboxEndpoint = "https://content.dropboxapi.com/2/files/upload";
let appToken = "<dropbox app token>";

// set up the post options
let postOptions = {
    method: "post",
    headers: {
        "Authorization" : "Bearer " + appToken,
        "Dropbox-API-Arg" : "{\"path\": \"/Apps/Airtable%20CSV%20Export/myData.csv\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}",
        "Content-Type" : "application/octet-stream",
        "Accept" : "application/json",
    },
    body: csvFile
}

const postResults = await fetch(dropboxEndpoint, postOptions);
const jsonPost    = await postResults.json();

// display the dropbox upload result
output.markdown("Display Drop[box Response JSON Object");
output.inspect(jsonPost);

//
// update the record with a csv from dropbox into the attachment field
//

// set the table name
let targetTableName = "CSV Files";

// get the target table
let targetTable = base.getTable(targetTableName);

// set the csv url (in dropbox)
let csvFileName = "myCSVFile.csv";
let csvURL = "https://www.dropbox.com/s/26krgxmdcxebu1h/myData.csv?dl=1";

// update the csv file record
await targetTable.updateRecordAsync("recM98pguTsI6CPeZ", {
    "Name" : "My CSV File",
    "Rows" : csvItemCount,
    "CSV File": [
        {
        "id"       : "attiRJr8Ih9v3etWi",
        "filename" : csvFileName,
        "url"      : csvURL
        }
    ]
})
3 Likes

We’ve built an extension that allows you to export your tables as CSVs. Markdowns are included in the exported files as well.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.