csv

Editing csv files in batch


i need to edit this csv file in batch

id;category;name/code;description;sku;price;weight;options;enable discounts;discounts;availability type;available;pending;images
iqhk8mjh;Software;Quick Heal Antivirus Pro;Quick Heal Antivirus Pro;quickh1;29,90;0;;0;;Dynamic;10;0;C:\Users\Matteo\Dropbox\siti\quick\av2021.png

i tryed with powershell


Solution

  • You can do it with PowerShell but I would recommend Miller (available here for several OSs) instead:

    mlr --icsv --ifs ';' --otsv cut -f 'id,price,available' then rename 'available,quantity' then filter '$quantity != 0' then put '$codice = 1234' file.csv
    

    Output:

    id        price  quantity  codice
    iqhk8mjh  29,90  10        1234
    
    Explanations

    note: then is for chaining operations in Miller