As front-end developers, we’ll most likely come across a time when we need to format data that has been given to us by a client or that has been exported from another site, that isn’t quite formatted the way we need it.
Since I am not a software engineer, I rely on plugins to solve a lot of my server side problems. Plugins will make things a lot easier for you but they aren’t always as robust as we’d like them to be. Sometimes getting your data the way you need it can present a challenge as well. So how does a front-end developer fix this problem?
Let’s say your client wants to export some pricing data from one site and import into another, and their old site formats data in separate cells:
Small Qty. | Small Price | Med Qty. | Med Price | Large Qty. | Large Price.
1-11 | $3.00 | 12-20 | $2.65 | 21+ | $1.34
But you need your data formatted differently for this new site you’re moving to. They require you to format your data in 1 cell.
(qty + ‘:’ + price + ‘|’ + qty + ‘:’ + price + ‘|’ + qty + ‘:’ + price + ‘| )
Step 1: create a spreadsheet / or upload existing
Step 2: Create new script file
By selecting Tools > Script Manager in the menu bar at the top you’ll bring up a screen that looks like this. Select New to start a new file.
Step 4: Using the code you’ve written