Python Automation and Machine Learning for EM and ICs

An Online Book, Second Edition by Dr. Yougui Liao (2019)

Python Automation and Machine Learning for EM and ICs - An Online Book

Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix

Automated Folder Generation from Structured CSV Data for Efficient Directory Management

The developed Python script (Code) automates the creation of subfolders based on structured data from a CSV file, using the values from three specified columns. Each row in the CSV contains a unique combination of identifiers: the first column includes a string composed of five letters followed by numbers, the second column begins with a letter followed by two digits, and the third column contains a letter-based code with a dot separator. The script reads the CSV file using the pandas library, extracts the values from each row, and constructs a folder name by concatenating the three column values with underscores. It then checks whether a folder with that name already exists in the specified base directory and creates it only if it does not already exist. This ensures efficient folder organization while preventing redundant directory creation, making the process suitable for managing large datasets or experiment logs in a structured and repeatable manner.