Icon

m_​001_​import

CSV files from subfolders to xlsx sheets

I created a workflow that demonstrates how such a job could be done. I use two loops. The first one lists all the folders from the import folder, the second one iterates thru all the CSV files found there.

The names of the folders and files are extracted and used to name the resulting Excel files. Maybe you could modify that to your needs.

using older KNIME nodeshttps://forum.knime.com/t/csv-files-from-subfolders-to-xlsx-sheets/16976/2?u=mlauber71 CSV files from subfolders to xlsx sheetshttps://forum.knime.com/t/read-multiple-csv-proceed-with-them-and-save-individually/44471/3?u=mlauber71please donwload the whole workflow group: https://hub.knime.com/mlauber71/spaces/Public/latest/forum/kn_example_csv_to_excel~9iINy9o1dygRQujC/ Process the CSV files from one sub-folder and collect them into an Excel file overview.xlsxknime://knime.workflow/../data/START inner loopEND Outer loopv_name_xls_fileEND inner loopextract namesList foldersknime://knime.workflow/../import/START Outer loopread CSV filesappend excel sheetsList folders../import/START Outer loopList CSV files in sub-folder of../import/START inner loopPath_Folderread CSV filesexcel_file../data/collected_new_<..>.xlsx)Path_stringPath_stringexcel_fileoverwrite if first loop// check the first iteration (0)if($${IcurrentIteration}$$ == null) { return 0;}else if ($${IcurrentIteration}$$ == 0) {return 0;}else {return 1;}folder_name_partcreate thename partwith the sub-folderone, two, three ...Path_Folder_stringPath_Folder_stringfolder_nameexcel_fileappend iffollowing loopEND inner loopEND Outer loopExcel Writer (XLS)(deprecated) List Files(deprecated) Table Row To VariableLoop Start (deprecated) Loop End(deprecated) Java EditVariable (simple) Variable Loop End(deprecated) URL to FilePath (Variable) Column Resorter List Folders Table Row To VariableLoop Start (deprecated) CSV Reader(deprecated) Sorter Excel Sheet Appender(XLS) (deprecated) List Files/Folders Table Row ToVariable Loop Start List Files/Folders Sorter Table Row ToVariable Loop Start Column Rename CSV Reader Create File/FolderVariables URL to FilePath (Variable) Path to String(Variable) Excel Writer CASE Switch Start Java EditVariable (simple) CASE Switch End Java EditVariable (simple) URL to FilePath (Variable) Path to String(Variable) ConstantValue Column Excel Writer Variable Loop End Loop End using older KNIME nodeshttps://forum.knime.com/t/csv-files-from-subfolders-to-xlsx-sheets/16976/2?u=mlauber71 CSV files from subfolders to xlsx sheetshttps://forum.knime.com/t/read-multiple-csv-proceed-with-them-and-save-individually/44471/3?u=mlauber71please donwload the whole workflow group: https://hub.knime.com/mlauber71/spaces/Public/latest/forum/kn_example_csv_to_excel~9iINy9o1dygRQujC/ Process the CSV files from one sub-folder and collect them into an Excel file overview.xlsxknime://knime.workflow/../data/START inner loopEND Outer loopv_name_xls_fileEND inner loopextract namesList foldersknime://knime.workflow/../import/START Outer loopread CSV filesappend excel sheetsList folders../import/START Outer loopList CSV files in sub-folder of../import/START inner loopPath_Folderread CSV filesexcel_file../data/collected_new_<..>.xlsx)Path_stringPath_stringexcel_fileoverwrite if first loop// check the first iteration (0)if($${IcurrentIteration}$$ == null) { return 0;}else if ($${IcurrentIteration}$$ == 0) {return 0;}else {return 1;}folder_name_partcreate thename partwith the sub-folderone, two, three ...Path_Folder_stringPath_Folder_stringfolder_nameexcel_fileappend iffollowing loopEND inner loopEND Outer loopExcel Writer (XLS)(deprecated) List Files(deprecated) Table Row To VariableLoop Start (deprecated) Loop End(deprecated) Java EditVariable (simple) Variable Loop End(deprecated) URL to FilePath (Variable) Column Resorter List Folders Table Row To VariableLoop Start (deprecated) CSV Reader(deprecated) Sorter Excel Sheet Appender(XLS) (deprecated) List Files/Folders Table Row ToVariable Loop Start List Files/Folders Sorter Table Row ToVariable Loop Start Column Rename CSV Reader Create File/FolderVariables URL to FilePath (Variable) Path to String(Variable) Excel Writer CASE Switch Start Java EditVariable (simple) CASE Switch End Java EditVariable (simple) URL to FilePath (Variable) Path to String(Variable) ConstantValue Column Excel Writer Variable Loop End Loop End

Nodes

Extensions

Links