Converting data to different formats with copilot

Recently, I got a question from a client if GitHub Copilot would be able to convert data from a table designer tool into working test files. The answer is probably yes! The only requirement is that the table designer tool is able to export its table (or tables) into a textual format, like SQL, JSON or CSV.

Here’s how you could achieve this with Copilot:

Step 1: Export the data

Export the data from the table designer tool into a textual format. For example, if the table designer tool is able to export the data into SQL, you could get a file like this:

CREATE TABLE BankTransactions ( 
    TransactionID INT PRIMARY KEY AUTO_INCREMENT, AccountNumber VARCHAR(20) NOT NULL, TransactionDate DATETIME NOT NULL, TransactionType ENUM('Deposit', 'Withdrawal', 'Transfer') NOT NULL, Amount DECIMAL(10, 2) NOT NULL, BalanceAfterTransaction DECIMAL(10, 2) NOT NULL, Description VARCHAR(255), RelatedAccountNumber VARCHAR(20), -- For transfer transactions 
    FOREIGN KEY (RelatedAccountNumber) REFERENCES BankAccounts(AccountNumber) 
);  

Step 2: Reference the target format

Open up your IDE and reference a file that has an example of the target formatting. For my use case, I want the SQL statement to be converted into markdown, in the format defined in my MyData.md file.

MyData.md

I open up the MyData.md file in my Jetbrains IDE and for good measure, add a reference to the file in my Copilot chat session by pressing the ‘+’ button:

Copilot chat session

Step 3: Ask Copilot to convert the data

Paste in the output from your designer tool, and ask copilot to convert it to the target format. In my case, I pasted in the SQL statement and asked Copilot to convert it to markdown using the following prompt:

CREATE TABLE BankTransactions ( TransactionID INT PRIMARY KEY AUTO_INCREMENT, AccountNumber VARCHAR(20) NOT NULL, TransactionDate DATETIME NOT NULL, TransactionType ENUM('Deposit', 'Withdrawal', 'Transfer') NOT NULL, Amount DECIMAL(10, 2) NOT NULL, BalanceAfterTransaction DECIMAL(10, 2) NOT NULL, Description VARCHAR(255), RelatedAccountNumber VARCHAR(20), -- For transfer transactions FOREIGN KEY (RelatedAccountNumber) REFERENCES BankAccounts(AccountNumber) );  

Fill in the file using the statement above

Data conversion result

And voila! Copilot has converted the SQL statement into markdown, ready to be used in my MyData.md file. Simply click the ‘insert into file’ button to insert the converted data into your file and you’re done!

Data conversion insert