arr1 = [[“devdb”,“emp_table”,“addedd”]]
arr2 = [[“devdb”,“cust_table”,“custname”,“deleted”]]
please help me how can get the above data in below form of csv data
dbname tablename column_name action
devdb emp_table nil added
devdb cust_table custname deleted
Hi, you could use arr1.flatten.join(“,”) or arr1.flatten.join(“;”).
Here is the doc of the method flatten https://apidock.com/ruby/Array/flatten
You’ll have to have some way of specifying that arr1
doesn’t contain a column_name
– either by inserting nil
or using a Hash instead ({dbname: 'devdb', tablename: 'emp_table', action: 'added'}
).
Once you’ve got that, @imperiumzigna’s suggestion will work – or you could use to_csv
instead of join
. (As a matter of fact, it seems you don’t need flatten
with join
, but you will with to_csv
.)
Personally I like to work with CSV::Table
rather than just CSV
, but it is a bit more complex and doesn’t natively support easy conversions from other data types.
Using Workato formula mode, filter records and select relevant fields for CSV.
Nested arrays or objects will simply be stringed and copied as is in each cell.
Has there been any fix created for this yet???