You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `DataTransferScript` is an Apps Script designed to streamline the process of copying specific data from one Google Sheets tab ("Raw data") to another ("[CLEANED] For import") in the ‘[Public] OpenMobilityData source updates’ google sheet and then updating column C in the ("[CLEANED] For import") tab based on conditions set. The script consists of two main functions: `copyData` and `updateDates`.
7
+
8
+
Script Functions
9
+
10
+
1. DataTransferScript():
11
+
Purpose: This function serves as the main function that calls the other two functions: `copyData` and `updateDates`.
12
+
13
+
Function Calls:
14
+
copyData(): Copies selected data from the "Raw data" tab to the "[CLEANED] For import" tab in the ‘[Public] OpenMobilityData source updates’ google sheet.
15
+
updateDates() : Updates dates in column B of the "[CLEANED] For import" tab based on the presence of data in column C in the ‘[Public] OpenMobilityData source updates’ google sheet.
16
+
17
+
2. copyData():
18
+
19
+
Purpose: Copies data from specific columns in the "Raw data" tab to corresponding columns in the "[CLEANED] For import" tab based on a user-specified row range.
20
+
21
+
Expected Inputs:
22
+
User input for the row range (e.g., a single row like 5 or a range like 3:10).
23
+
24
+
Expected Outputs:
25
+
Data from the selected rows and specified columns in the "Raw data" tab is copied to the corresponding columns in the "[CLEANED] For import" tab.
26
+
27
+
28
+
3. updateDates():
29
+
30
+
Purpose: Updates the date in column B of the "[CLEANED] For import" tab if the corresponding cell in column C is not empty.
31
+
32
+
Expected Inputs:
33
+
The function operates on the data present in columns B and C of the active sheet.
34
+
35
+
Expected Inputs:
36
+
Column B is updated with the current date if the corresponding cell in column C has a value. If column C is empty, the corresponding cell in column B is cleared.
37
+
38
+
39
+
How to run the script:
40
+
41
+
1. Open the ‘[Public] OpenMobilityData source updates’ google sheet.
42
+
2. Go to the "[CLEANED] For import" tab.
43
+
3. Click on the “Data Transfer” button.
44
+
4. Input desired row number or range you want to copy from the ("Raw data") tab.
45
+
5. The `DataTransferScript` validates the input and converts it into a list of row numbers.
46
+
6. Specific columns are copied from the source tab ("Raw data") to the destination tab ("[CLEANED] For import") based on the user's input.
47
+
7. The copied data is pasted into the appropriate columns starting from the first available row in the destination tab.
48
+
8. The `updateDates()` function is called to update the dates in column B of the "[CLEANED] For import" tab based on the presence of data in column C.
49
+
9. The `updateDates() script iterates through all rows starting from row 2 (to avoid the header)
50
+
10. It checks if each cell in column C has a value.
51
+
11. If a value exists, the corresponding cell in column B is updated with the current date.
52
+
12. If no value exists in column C, the corresponding cell in column B is cleared.
53
+
54
+
*/
55
+
56
+
57
+
// Running the Script Code
58
+
59
+
60
+
functionDataTransferScript(){
61
+
62
+
copyData();
63
+
64
+
// Update dates based on column C
65
+
updateDates();
66
+
}
67
+
68
+
functioncopyData(){
69
+
// Get the spreadsheet and source/destination tabs
0 commit comments