Icon

SplitFileAndSaveIntoSubfolders

A pharmaceutical company used to keep its sales data in a CSV file. They ask for your help to split the data into monthly CSV files and to save them into different subfolders, where each subfolder corresponds to a year.

This is my solution.

(RELATIVE,knime.workflow.data,sales_data.csv)Date onlylocale: en_GBExtract Yearand Month (name)locale: en_GBGroupByYear and Month(name)(RELATIVE,knime.workflow.data,file_path_name)ExtractYear and Month(name)only Original ColumnsNode 12file_path_nameString(Year)+"/"+Monath(name)+".csv"Loop over all groupsCSV Reader String to Date&Time Extract Date&TimeFields Group Loop Start String to Path(Variable) Table Rowto Variable Column Filter CSV Writer String Manipulation(Variable) Variable Loop End (RELATIVE,knime.workflow.data,sales_data.csv)Date onlylocale: en_GBExtract Yearand Month (name)locale: en_GBGroupByYear and Month(name)(RELATIVE,knime.workflow.data,file_path_name)ExtractYear and Month(name)only Original ColumnsNode 12file_path_nameString(Year)+"/"+Monath(name)+".csv"Loop over all groupsCSV Reader String to Date&Time Extract Date&TimeFields Group Loop Start String to Path(Variable) Table Rowto Variable Column Filter CSV Writer String Manipulation(Variable) Variable Loop End

Nodes

Extensions

Links