Рет қаралды 26,701
Let me show you how you can use a Microsoft Office Script to convert your CSV into Excel and further extend it to handle Mac/Unix file encodings and implement a table for later use in your Cloud Flow. No need for a premium or 3rd party connector. Much easier than using select/compose and apply to each. No need to worry about quote encapsulated values as the Microsoft Team have handled this with a regular expression.
Microsoft Script Example
docs.microsoft.com/en-us/offi...
How to Create a New Excel File using Compose
• Create a new Excel Fil...
00:00 Intro
00:44 Quick exploration of CSV's with different file encodings
01:26 Build our script using sample Microsoft Office Script
02:50 Building our Cloud Flow based on 3 sample files
06:09 Don't forget your file get file content!
07:01 Save, explanation of Logic and Test
08:30 Our Excel files but with Encoding problems demonstrated
09:06 Extend the script to handle file encodings and add a table
12:16 Looking at the newly converted CSV to Excel with encodings handled
13:00 Querying an excel file with the Table inserted during the Office Script Action
14:25 Summary and close
Additional Script for File Encodings (**NOTE** replace string GREATER with angled bracket as YT will not allow it in desc)
let rows = csv.split("
");
// Split each line into a row.
if (csv.search(/
/) GREATER -1) {
rows = csv.split("
");
} else if (csv.search(/
/) GREATER -1) {
rows = csv.split("
");
} else if (csv.search(/
/) GREATER -1) {
rows = csv.split("
");
}
Additional Script for adding a table to your Excel File
// Get the first worksheet
const selectedSheet = workbook.getFirstWorksheet();
// Create a table using the data range.
let newTable = workbook.addTable(selectedSheet.getUsedRange(), true);
newTable.setName("NewTableInExcel");
My previous attempt at converting CSV to JSON using Select/Compose and Apply to Each and an explanation of file encodings:
www.damobird365.com/how-to-pa... Please buy me a coffee www.buymeacoffee.com/DamoBird365 ☕