Electron microscopy
 
CSV Column Transposer
- Python for Integrated Circuits -
- An Online Book -
Python for Integrated Circuits                                                                                   http://www.globalsino.com/ICs/        


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

=================================================================================

CSV Column Transposer: Code:
         Upload Files to Webpages
       Input and output:    
         Upload Files to Webpages
         Upload Files to Webpages

The script above is a Python script that performs the following tasks: 
           It initializes an empty DataFrame called transposed_df with columns 'xyz', 'ASDFJ::SDF:SDDF', 'Hellow', and 'Merged (UVXY)'. These columns are used to store the transposed data.
          It iterates through each row in the df DataFrame using a for loop. For each row: It extracts the values of 'xyz' and 'ASDFJ::SDF:SDDF' columns from the original row.
          It then enters a nested loop that iterates through all columns in the row (i.e., it iterates through each column in the original DataFrame, including columns with '(UVXY)' in the header).           For each column:
                    It checks if the column name contains '(UVXY)' by using the if '(UVXY)' in col_name condition.
                    If the column contains '(UVXY)', it extracts the 'Hellow' value by splitting the column name at the '(' character. This is done to create the 'Hellow' column in the transposed DataFrame.
          It appends a new row to the transposed_df DataFrame with the 'xyz', 'ASDFJ::SDF:SDDF', 'Hellow', and 'Merged (UVXY)' values. This effectively transposes the data into a format           where each '(UVXY)' value is associated with its corresponding 'Hellow' value, 'xyz', and 'ASDFJ::SDF:SDDF'.
          After the iteration is complete, the script has created the transposed_df DataFrame with the desired transposed format.
          It then creates a temporary CSV file using tempfile.NamedTemporaryFile and writes the data from the transposed_df DataFrame into this temporary file using to_csv.
          The temporary file is copied to the specified outputFile location using shutil.copy.
          Finally, the script opens the outputFile and prints its contents, showing you the resulting transposed data in the desired format.

This script essentially transposes the data from a wide format (with multiple '(UVXY)' columns) into a long format with three columns ('xyz', 'ASDFJ::SDF:SDDF', and 'Merged (UVXY)') and multiple rows.

============================================

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 



















































 

 

 

 

 

=================================================================================