MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / rowToProto

Function rowToProto

dlp/deidentifyWithDateShift.js:79–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77
78 // Helper function for converting CSV rows to Protobuf types
79 const rowToProto = row => {
80 const values = row.split(',');
81 const convertedValues = values.map(value => {
82 if (Date.parse(value)) {
83 const date = new Date(value);
84 return {
85 dateValue: {
86 year: date.getFullYear(),
87 month: date.getMonth() + 1,
88 day: date.getDate(),
89 },
90 };
91 } else {
92 // Convert all non-date values to strings
93 return {stringValue: value.toString()};
94 }
95 });
96 return {values: convertedValues};
97 };
98
99 async function deidentifyWithDateShift() {
100 // Read and parse a CSV file

Callers 1

deidentifyWithDateShiftFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected